Hi I have the following code
for j = 1:2,
for i = 1:24,
for K = 1:3,
for M = 1:3,
PV_output(:,:,K) = real(PV_power_output(:,:,K));
WT_output(:,:,M) = WT_power_output(:,:,M);
PVenergy = sum(sum(PV_output(:,:,1)));
WTenergy = sum(sum(WT_power_output(:,:,1)));
f = [((CRF*CC_PV)/PVenergy)+OM_PV; ((CRF*CC_WT)/WTenergy)+OM_WT];
A = [-PV_output(j,i,K) -WT_output(j,i,M)];
b = -Demand(j,i);
lb = zeros(2,1);
ub = [max_PV_area/PV_area max_WT_area/WT_area]';
end
end
end
end
PV_output and WT_output are 365 x 24 matrices with three different sets of matrices that I am trying to examine individually..Demand is a 365 x 24 matrix.
When I run linprog it seems that it is only reading the last element of the above matrices and also when I check the size of A and b I get a 1×2 and 1×1 whereas I should be getting a 365x24x3 and 365×24
Any help?!
When you do this
you are assigning A to be a 1 x 2 array at every iteration. The variable returned by
-PV_output(j,i,K)and-WT_output(j,i,M)are scalars, so you should not expect A to be anything other an 1 x 2 in size.Similarly
simply returns a scalar element of the
Demandmatrix and sobhas size 1 x 1.It would appear that you wish to use these values as elements in a much larger matrix so you should assign them to the appropriate indices in your matrices A and b.
Something along the lines of
where index1 and index2 specify the position in
bat which you want them stored. By storing the value at a particular (appropriate) element in the matrix b rather than overwriting it each time as you currently are, you should get what you want by working out the appropriate indices at each iteration. Similarly if A is 3 dimensional array then you need something similar but with 3 indices.I cannot give you an in code solution as you have 4 loops here and it is not clear to me exactly what data you are storing. Maybe someone else can give you an exact line for line solution, but if not I hope this provides enough help for you to see what needs to be done to fix the problem.