This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

Code Generation

Generate code and deploy controllers on real-time targets

Once you have validated a model predictive controller in Simulink® or MATLAB®, you can generate code and deploy it for real-time control applications. For more information, see Generate Code and Deploy Controller to Real-Time Targets.


expand all

reviewExamine MPC controller for design errors and stability problems at run time
mpcmoveCodeGenerationCompute optimal control moves with code generation support
getCodeGenerationDataCreate data structures for mpcmoveCodeGeneration
mpcqpsolverSolve a quadratic programming problem using the KWIK algorithm
mpcqpsolverOptionsCreate default option set for mpcqpsolver


expand all

MPC ControllerCompute MPC control law
Adaptive MPC ControllerDesign and simulate adaptive and time-varying model predictive controllers
Explicit MPC ControllerDesign and simulate explicit model predictive controller
Multiple MPC ControllersSimulate switching between multiple implicit MPC controllers
Multiple Explicit MPC ControllersSimulate switching between multiple explicit MPC controllers
Adaptive Cruise Control SystemSimulate adaptive cruise control using model predictive controller
Lane Keeping Assist SystemSimulate lane-keeping assistance using adaptive model predictive controller


Getting Started

Generate Code and Deploy Controller to Real-Time Targets

Model Predictive Control Toolbox™ software provides code generation functionality for controllers designed in Simulink and MATLAB.

QP Solver

The model predictive controller QP solver converts an MPC optimization problem to a general form quadratic programming problem.

Simulink Code Generation

Simulation and Code Generation Using Simulink Coder

Simulate your MPC controller in Simulink and generate real-time code that uses either double or single precision signals.

Simulation and Structured Text Generation Using PLC Coder

Simulate your MPC controller in Simulink and generate structured text for programmable logic controllers.

MATLAB Code Generation

Generate Code To Compute Optimal MPC Moves in MATLAB

Generate C code to compute manipulated variable moves for real-time applications.

Custom QP Solver

Simulate and Generate Code for MPC Controller with Custom QP Solver

Generate code for a model predictive controller that uses a custom quadratic programming solver.

OPC Simulation

Real-Time Control with OPC Toolbox

Implement an online model predictive controller application using the OPC client supplied with the OPC Toolbox™.

Was this topic helpful?