Arrays have incompatible sizes for this operation.

1 visualización (últimos 30 días)
jana nassereddine
jana nassereddine el 22 de Mayo de 2023
Movida: Steven Lord el 22 de Mayo de 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

Respuesta aceptada

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

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Mathematics en Help Center y File Exchange.

Productos


Versión

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by