MATLAB Examples

Designing a Model Predictive Controller in Simulink®

This example shows how to design a model predictive controller by first from linearizing a nonlinear plant in Simulink® .


Open Simulink Model

To run this example, Simulink® and Simulink Control Design® are required.

if ~mpcchecktoolboxinstalled('simulink')
    disp('Simulink(R) is required to run this example.')
if ~mpcchecktoolboxinstalled('slcontrol')
    disp('Simulink Control Design(R) is required to run this example.')

Open a Simulink model with an MPC Controller block connected to a plant model block.

mdl = 'mpc_linearization';

Open MPC Controller block dialog. No MPC controller is defined in the MPC Controller block yet.

open_system([mdl '/MPC Controller']);

Linearize Plant and Launch MPC Designer App

Click the "Design" button in the MPC block dialog to launch the MPC Designer app.

Click the "MPC Structure" button to launch the "Define MPC Structure By Linearization" dialog, where you can specify the MPC structure information for your design. Validate that the I/O signal sizes, controller sample time, operating point and Simulink signals are the desired values.

Click the "Define and Linearize" button. The app will linearize the Simulink plant at the specified operating point and use the linearized model as the internal predictive model in the MPC controller. Default plant, controller and simulation scenario are created and initial closed-loop reference tracking responses are plotted. You can continue your controller design in the "Tuning" tab.