How do i define and extract the MPC constraints?
3 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
I have my algorithm I wanna validate against the Matlab constraint generator. There is the function: https://se.mathworks.com/help/mpc/ref/mpc.getconstraint.html
What I want to do i to define my constraints variables i.e., min max and so, and then extract the matrices. The function example extracts the already given matrices (so its redundant i feel???). How do I do the opposite? I have tried to see what changed about the mpcobject before and after the constraints were defined. How do I do this? I have this attempt below which should have worked but does not.
n=4;
p=2;
hp=10;
hu=5;
Sys=ss(eye(n),eye(n,p),eye(n),0);
mpcobj = mpc(Sys,0.1);
mpcobj.PredictionHorizon=hp;
mpcobj.ControlHorizon=hu;
mpcobj.ManipulatedVariables(1).Min = -20;
mpcobj.ManipulatedVariables(2).Min = -20;
mpcobj.ManipulatedVariables(1).Max = 20;
mpcobj.ManipulatedVariables(2).Max = 20;
mpcobj.ManipulatedVariables(1).RateMin = -0.5;
mpcobj.ManipulatedVariables(2).RateMin = -0.5;
mpcobj.ManipulatedVariables(1).RateMax = 0.5;
mpcobj.ManipulatedVariables(2).RateMax = 0.5;
mpcobj.OutputVariables(1).Min = -500;
mpcobj.OutputVariables(2).Min = -500;
mpcobj.OutputVariables(3).Min = -500;
mpcobj.OutputVariables(4).Min = -500;
mpcobj.OutputVariables(1).Max = 500;
mpcobj.OutputVariables(2).Max = 500;
mpcobj.OutputVariables(3).Max = 500;
mpcobj.OutputVariables(4).Max = 500;
%%
[E,F,G] = getconstraint(mpcobj)
0 Commenti
Risposte (1)
Emmanouil Tzorakoleftherakis
il 13 Ott 2023
The getconstraint function is supposed to return mixed input/output constraints. One use case would be that someone creates the MPC object and you want to see what the input/output constraints look like.
The constraints you have defined are simple bounds so they don't fall under this category.
In any case, if you want to display the constraints you have defined, you can simply do
>>mpcobj
and you will see all relevant information about the mpc object.
Vedere anche
Categorie
Scopri di più su Refinement in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!