How to include a model (created by me at Simulink) in Matlab script?

5 Ansichten (letzte 30 Tage)
so I have model predictive controller with a plant model, and I created the plant model using blogs, I couldn't use the state space representation because I have a disturbance acting on the system, so the only way to include it is by making the model with a blocks,
so anyway now i am writing a code for custom state estimation in script, and I need to mention the plant model I have used in this script, but when I write the name of the plant model or the name of the plant model with MPC, an error appears as
"error using mpc, the first input argument of the mpc command must be an LTI object or a structure of models and offsets"
so my question is how to include the model (I have created using block ) into my script?
% Custom State Estimation
ts=0.1;
mpcobj=mpc('plantmodel',ts)
setEstimator(mpcobj,'custom');
xmpc = mpcstate(mpcobj);
A=[1 0;0 1];
B=[0.0936 0.0936 0;0 0.0752 0];
C=[1 0;0 1];
Nc=2;
SOCpbref=75; % (en pourcentage)
SOCliref=85; % (en pourcentage)
t=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)/t;
Cli= sum(Ili)/t;
SOCpb=(Cpb/Cmaxpb);
SOCli=(Cli/Cmaxli);
for t = 0:Nc
y = sys.C*xsys; % plant equations: output
YY(t+1) = y;
xmpc.Plant = [SOCpb, SOCli]; % state estimation
u = mpcmove(mpcobj,xmpc,[],[SOCpbref, SOCliref]); % y is not needed
UU(t+1) = u;
xsys = sys.A*xsys + sys.B*u; % plant equations: next state
end
command window:
Error using mpc
The first input argument of the "mpc" command must be an LTI object or a structure of models and offsets.
Error in customstateestimation (line 3)
mpcobj=mpc('model',ts)

Akzeptierte Antwort

Paul
Paul am 20 Mai 2023
Hi jana,
Can you clarify this statement: "I couldn't use the state space representation because I have a disturbance acting on the system,"
The state space ss object can include all inputs to the system, i.e., control, disturbance, noise, etc.
  10 Kommentare
jana nassereddine
jana nassereddine am 21 Mai 2023
okay that's great, but the ouput of this is it the same picture I showed it to you? or maybe I should try and see, what do you think?
Paul
Paul am 21 Mai 2023
Bearbeitet: Paul am 22 Mai 2023
Well, the picture showed did not define the output of the system, so I can't say.
I suggest reading the documentation and examples for the MPC toolbox and try to apply that material to the problem of interest.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (1)

Emmanouil Tzorakoleftherakis
Hi,
Currently you cannot use a Simulink model as prediction model for MPC design. This is something we are working towards for a future release. Since it seems you are designing a linear MPC controller, you could linearize your Simulink model at the desired operating point to get a linear representation, or you could use system identification as well if you are fine with a data-driven model. Here are a couple of examples:
Hope this helps

Kategorien

Mehr zu Linear Plant Specification finden Sie in Help Center und File Exchange

Produkte


Version

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by