high-dimensional slicing is very slow and inefficient, and you are doing that in several layers deep for-loops. If you profile it you'll see this for instance
for t = 1:96
Constraints = [Constraints,-mu_ctb(c,b,t) + mu_nt(1,1,t,w) - xi_ctb_D_lower(c,b,t,w) + xi_ctb_D_upper(c,b,t,w) - xi_ct_Dsum_lower(c,1,t,w) + xi_ct_Dsum_upper(c,1,t,w) == 0];
Constraints = [Constraints, 0 <= P_ctb_D(c,b,t,w) - P_ctb_D_min <= M*b_D1(c,b,t,w), 0 <= xi_ctb_D_lower(c,b,t,w) <= M*(1-b_D1(c,b,t,w))];
Constraints = [Constraints, 0 <= P_ctb_D_max(c,b,t) - P_ctb_D(c,b,t,w) <= M*b_D2(c,b,t,w), 0 <= xi_ctb_D_upper(c,b,t,w) <= M*(1-b_D2(c,b,t,w))];
end
is completely bogging down the process. Simply vectorizing the loop in t drops that part by a factor of close to 100.
You just have to go through the code and get rid of unnecessary loops. There are loads of them.
Where you cannot, you should make sure the small loops are in the outer layers so the the vectorization is done on large slices
for i = 1:5
for j=1:5
for k = 1:96
x(i,j,k)
replaced with
for i = 1:5
for j=1:5
x(i,j,:)
is going to have a much larger impact than rewrtting
for i = 1:96
for j=1:5
for k = 1:5
x(i,j,k)
to
for i = 1:96
for j=1:5
x(i,j,:)