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

조회 수: 4 (최근 30일)
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)

채택된 답변

Paul
Paul 2023년 5월 20일
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
jana nassereddine
jana nassereddine 2023년 5월 21일
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 2023년 5월 21일
편집: Paul 2023년 5월 22일
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.

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

추가 답변 (1개)

Emmanouil Tzorakoleftherakis
Emmanouil Tzorakoleftherakis 2023년 5월 23일
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

카테고리

Help CenterFile Exchange에서 Linear Plant Specification에 대해 자세히 알아보기

제품


릴리스

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by