| Model Predictive Control Toolbox | |
| Provide feedback about this page |
Simulate closed-loop/open-loop response to arbitrary reference and disturbance signals
Syntax
sim(MPCobj,T,r) sim(MPCobj,T,r,v) sim(MPCobj,T,r,SimOptions) or sim(MPCobj,T,r,v,SimOptions) [y,t,u,xp,xmpc,SimOptions]=sim(MPCobj,T,...)
Description
The purpose of sim is to simulate the MPC controller in closed loop with a linear time-invariant model, which, by default, is the plant model contained in MPCobj.Model.Plant. As an alternative, sim can simulate the open-loop behavior of the model of the plant, or the closed-loop behavior in the presence of a model mismatch between the prediction plant model and the model of the process generating the output data.
simulates the closed-loop system formed by the plant model specified in MPCobj.Model.Plant and by the MPC controller specified by the MPC object sim(MPCobj,T,r)
MPCobj, and plots the simulation results. T is the number of simulation steps. r is the reference signal array with as many columns as the number of output variables.
also specifies the measured disturbance signal sim(MPCobj,T,r,v)
v, that has as many columns as the number of measured disturbances.
Note
The last sample of r/v is extended constantly over the simulation horizon, to obtain the correct size.
|
sim(MPCobj,T,r,SimOptions) or sim(MPCobj,T,r,v,SimOptions) specifies the simulation options object SimOptions, such as initial states, input/output noise and unmeasured disturbances, plant mismatch, etc. See mpcsimopt for details.
Without output arguments, sim automatically plots input and output trajectories.
[y,t,u,xp,xmpc,SimOptions]=sim(MPCobj,T,...) instead of plotting closed-loop trajectories returns the sequence of plant outputs y, the time sequence t (equally spaced by MPCobj.Ts), the sequence u of manipulated variables generated by the MPC controller, the sequence xp of states of the model of the plant used for simulation, the sequence xmpc of states of the MPC controller (provided by the state observer), and the options object SimOptions used for the simulation.
The descriptions of the input arguments and their default values are shown in the table below.
| Input Argument |
Description |
Default |
|---|---|---|
MPCobj |
MPC object specifying the parameters of the MPC control law |
None |
T |
Number of simulation steps |
Largest row-size of r,v,d,n |
r |
Reference signal |
MPCobj.Model.Nominal.Y |
v |
Measured disturbance signal |
Entries from MPCobj.Model.Nominal.U |
SimOptions |
Object of class @mpcsimopt containing the simulation parameters (See mpcsimopt) |
[] |
r is an array with as many columns as outputs, v is an array with as many columns as measured disturbances. The last sample of r/v/d/n is extended constantly over the horizon, to obtain the correct size.
The output arguments of sim are detailed below.
Examples
We want to simulate the MPC control of a multi-input single-output system (the same model as in demo misosim.m). The system has one manipulated variable, one measured disturbance, one unmeasured disturbance, and one output.
%Plant model and initial state sys=ss(tf({1,1,1},{[1 .5 1],[1 1],[.7 .5 1]})); % MPC object setup Ts=.2; % sampling time sysd=c2d(sys,Ts); % prediction model % Define type of input signals sysd=setmpcsignals(model,'MV',1,'MD',2,'UD',3); MPCobj=mpc(sysd); % Default weights and horizons % Define constraints on manipulated variable MPCobj.MV=struct('Min',0,'Max',1); Tstop=30; % Simulation time Tf=round(Tstop/Ts); % Number of simulation steps r=ones(Tf,1); % Reference trajectory v=[zeros(Tf/3,1);ones(2*Tf/3,1)]; % Measured dist. trajectory sim(MPCobj,Tf,r,v);
See Also
| Provide feedback about this page |
![]() | setoutdist | size | ![]() |
| © 1984-2008- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |