Plot responses generated by MPC simulations
Use the Model Predictive Control Toolbox™
plot function to plot responses generated by MPC
To create 2-D line plots of data points instead, see
Plot Responses from MPC Simulation
Create a plant, a corresponding MPC object, and convert it to zero/pole/gain form.
mpcverbosity off; % turn off mpc messaging plant=tf(1,[1 -1 1],0.2); % create plant (0.2 seconds sampling time) mpcobj=mpc(plant,0.2); % create mpc object (0.2 second sampling time) [y,t,u,xp]=sim(mpcobj,10,1); % simulate closed loop for 10 steps plot(mpcobj,t,y,ones(size(y)),u); % plot response % You can plot other data. The signal type definitions and labels are contained in mpcobj plot(mpcobj,1:10,rand(10,1),zeros(10,1),sin(1:10)'); % random response
t — Time sequence
Time sequence, specified as an
Nt-by-1 array, where
Nt is the number of simulation steps.
y — Sequence of plant outputs values
Sequence of plant outputs values, specified as an array of output responses of size
Ny is the
number of measured outputs of the plant.
r — Sequence of reference values
Sequence of reference values for the plant output. It is an array of setpoints and
has the same size as
u — Sequence of manipulated variables
Sequence of manipulated variables, specified as an array of manipulated variable
inputs of size
Nu is the number of manipulated variables.
v — Sequence of measured disturbances inputs
 (default) |
Sequence of measured disturbances input, specified as a matrix of size
Nv is the
number of measured disturbance inputs.
d — Sequence of unmeasured disturbances inputs
 (default) |
Sequence of unmeasured disturbances inputs, specified as an array of size
Nd is the
number of unmeasured disturbances inputs.