The number of rows in A must be the same as the number of elements of b.
古いコメントを表示
%% Discrete modelling
Ae=(1-(K*ts)/Cth);
Be=(ts*COP*HP)/Cth;
D=ts*K/Cth;
Tin=zeros(1,i);
u=zeros(1,i);
for j=1:i
% f=@(u) sum(u(j)*gamma(j));
f=u(j);
%%%Starting point%%%
u0=0;
if j>1
Tin(j+1)=Ae*Tin(j)+Be*u(j)+D*Tout(j);
else
Tin(j)=0;
end
%%%Constraints%%%
%%%Equality%%%%
Aeq=Be;
beq=(Tin(j+1)-Ae*Tin(j)-D*Tout(j));
%%%Inequality%%%
A=[(Tin(j)*Be)/(Tin(j+1)-Ae*Tin(j)-D*Tout(j)) ;(-(Tin(j)*Be)/(Tin(j+1)-Ae*Tin(j)-D*Tout(j)))];
b=[Tmax ; -Tmin];
options = optimoptions(@linprog,'Display', 'off');
u(j)=linprog(f,u0,A,b,Aeq,beq,umin,umax,options);
end
I am getting the error: The number of rows in A must be the same as the number of elements of b.
Does anyone know why?
Thanks!
4 件のコメント
Please provide the entire error message and indicate which line the error comes from (most likely from the line containing linprog()).
"Does anyone know why? "
Yes, because the number of rows of 'A' (size(A,1)) is not the same as the number elements in 'b' (numel(b)).
Ricardo López
2020 年 10 月 20 日
Walter Roberson
2020 年 10 月 20 日
We cannot tell. There are too many variables that you do not show us the size of.
Look at size(A) and size(b) and look at the size of the variables used to construct A and b
Ricardo López
2020 年 10 月 20 日
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Linear Programming and Mixed-Integer Linear Programming についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!