Filter löschen
Filter löschen

Arrays have incompatible sizes for this operation.

2 Ansichten (letzte 30 Tage)
jana nassereddine
jana nassereddine am 22 Mai 2023
Verschoben: Steven Lord am 22 Mai 2023
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

Akzeptierte Antwort

KSSV
KSSV am 22 Mai 2023
Verschoben: Steven Lord am 22 Mai 2023
sys.B is of size 2x4 and u is of size 3x1....how you can multiply them?
  1 Kommentar
jana nassereddine
jana nassereddine am 22 Mai 2023
Verschoben: Steven Lord am 22 Mai 2023
thank you, that's true, but i cannot accept your answer because it is written as a comment

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Produkte


Version

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by