Arrays have incompatible sizes for this operation.

조회 수: 1 (최근 30일)
jana nassereddine
jana nassereddine 2023년 5월 22일
이동: Steven Lord 2023년 5월 22일
Hello,
I have this code with this error, can anyone help me please?
% Custom State Estimation
Ts=1;ts=0.1;
A=[1 0;0 1];
B=[0.0936 0.0936 0 0.0936;0 0.0752 0 0];
C=[1 0;0 1];
D=[0 0 0 0; 0 0 0 0];
plant = ss(A,B,C,D);
plant = setmpcsignals(plant,MV=[1 2 3],MD=4)
mpcobj=mpc(plant,ts,10,3)
setEstimator(mpcobj,'custom');
sys=c2d(ss(plant),Ts);
xsys=[0;0];
xmpc = mpcstate(mpcobj);
SOCpbref=75; % (en pourcentage)
SOCliref=85; % (en pourcentage)
t1=25; % en seconds
Cmaxpb=22020; % As (Ampersecond)
Cmaxli=6000; % As (Ampersecond)
Ipb=[60 65 70 75 65 60 55 50 50 50 55 60 65 70 75 75 75 75 70 60 60 55 65 60 50]; % en Ampere
Ili=[70 75 80 85 75 70 65 60 60 60 65 70 75 80 85 85 85 85 80 70 70 65 75 70 60]; % en Ampere
Cpb= sum(Ipb)/t1;
Cli= sum(Ili)/t1;
SOCpb=(Cpb/Cmaxpb);
SOCli=(Cli/Cmaxli);
for t = 0:3
y = sys.C*xsys; % plant equations: output
YY = y;
xmpc.Plant = [SOCpb, SOCli]; % state estimation
u = mpcmove(mpcobj,xmpc,[],[SOCpbref, SOCliref]); % y is not needed
UU = u;
xsys = sys.A.*xsys + sys.B.*u; % plant equations: next state
end
Arrays have incompatible sizes for this operation.
Error in customstateestimation (line 35)
xsys = sys.A.*xsys + sys.B.*u; % plant equations: next state

채택된 답변

KSSV
KSSV 2023년 5월 22일
이동: Steven Lord 2023년 5월 22일
sys.B is of size 2x4 and u is of size 3x1....how you can multiply them?
  댓글 수: 1
jana nassereddine
jana nassereddine 2023년 5월 22일
이동: Steven Lord 2023년 5월 22일
thank you, that's true, but i cannot accept your answer because it is written as a comment

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

추가 답변 (0개)

카테고리

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

제품


릴리스

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by