Arrays have incompatible sizes for this operation.

2 ビュー (過去 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 Center および File ExchangeLogical についてさらに検索

製品


リリース

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by