Hi
Im doing a nonlinear optimization using fmincon that includes nonlinear equality constraints linear inequality constraints (These depend on values from two excel spreadsheets.
This is my code for the A and b matrices for j=1:3 for i=1:5
L = xlsread('hourly electric demand.xlsx'); Lth = xlsread('hourly thermal demand.xlsx'); if xin(1)>= L(j,i) && xin(2)>=Lth(j,i); A(1,:)=[FIT RHI 0 0 -(FIT-Xe);-1 0 -1 0 0; 0 -1 0 -1 0]; b = [max(Pe*L(j,i))+Pth*max(Lth(j,i))+ Operation; -L(j,i);... -Lth(j,i)]; elseif xin(1)<=L(j,i) && xin(2)<=Lth(j,i); A(2,:)=[FIT RHI -Pe -Pth 0;-1 0 -1 0 0; 0 -1 0 -1 0]; b = [max(Pe*L(j,i)+Pth*Lth(j,i))+ Operation;-L(j,i); -Lth(j,i)]; elseif xin(1)>=L(j,i) && xin(2)<=Lth(j,i); A(3,:)=[FIT RHI 0 -Pth -(FIT-Xe);-1 0 -1 0 0; 0 -1 0 -1 0]; b = [max(Pe*L(j,i)+Pth*Lth(j,i))+ Operation; -L(j,i); -Lth(j,i)]; elseif xin(1)<= L(j,i) && xin(2)>= Lth(j,i); A(4,:)=[FIT RHI -Pe -Pth 0;-1 0 -1 0 0; 0 -1 0 -1 0]; b = [max(Pe*L(j,i)+Pth*Lth(j,i))+ Operation; -L(j,i); -Lth(j,i)]; end endend
and this is the code for the objective function
f = sum(((0.537*(L(j,i)-xin(1)))+(0.185*(Lth(j,i)-xin(2)))));
However I am getting the following error
??? Subscripted assignment dimension mismatch.
Error in ==> invoke at 42 A(1,:)=[FIT RHI 0 0 -(FIT-Xe);-1 0 -1 0 0; 0 -1 0 -1 0];
Do I need to make changes to the objective function since it only includes xin(1) and xin(2) whereas I am constraining to 5 difference xin?
thanks
Best Answer