필터 지우기
필터 지우기

The number of rows in A must be the same as the number of elements of b.

조회 수: 14 (최근 30일)
%% 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
Walter Roberson
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
Ricardo López 2020년 10월 20일
i=1008,
size(Tout) is 1 1008
umin, umax Tmin Tmax sizes are 1 1.
Ae, Be, D are also constants.
Thanks!

댓글을 달려면 로그인하십시오.

채택된 답변

Walter Roberson
Walter Roberson 2020년 10월 20일
MATLAB function calls use positional parameters, not named parameters. The second parameter you are passing, u0, is getting received in the slot where the linear constraints matrix is expected, so you are setting your constraints matrix to scalar 0. Your variable named A is being received in the linear constraints outcome vector, and has two elements, which is not the same as the number of rows of your scalar u0.
Your u0 parameter should not be present.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by