Main Content


Plot responses generated by MPC simulations


Use the Model Predictive Control Toolbox™ plot function to plot responses generated by MPC simulations.

To create 2-D line plots of data points instead, see plot.


plot(MPCobj,t,y,r,u,v,d) plots the results of a simulation based on the MPC object MPCobj.


collapse all

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

Input Arguments

collapse all

Model predictive controller, specified as an MPC controller object. To create an MPC controller, use mpc.

Time sequence, specified as an Nt-by-1 array, where Nt is the number of simulation steps.

Example: 1:10

Sequence of plant outputs values, specified as an array of output responses of size Nt-by-Ny, where Ny is the number of measured outputs of the plant.

Example: rand(10,1)

Sequence of reference values for the plant output. It is an array of setpoints and has the same size as y.

Example: ones(10,1)

Sequence of manipulated variables, specified as an array of manipulated variable inputs of size Nt-by-Nu, where Nu is the number of manipulated variables.

Example: sin(1:10)'

Sequence of measured disturbances input, specified as a matrix of size Nt-by-Nv, where Nv is the number of measured disturbance inputs.

Example: zeros(10,1)

Sequence of unmeasured disturbances inputs, specified as an array of size Nt-by-Nd, where Nd is the number of unmeasured disturbances inputs.

Example: zeros(10,1)

See Also


Introduced before R2006a