Simulation and Code Generation Using Simulink Coder

This example shows how to simulate and generate real-time code for an MPC Controller block with Simulink® Coder™. Code can be generated in both single and double precisions.

Required Products

To run this example, Simulink and Simulink Coder are required.

if ~mpcchecktoolboxinstalled('simulink')
disp('Simulink is required to run this example.')
returnendif ~mpcchecktoolboxinstalled('simulinkcoder')
disp('Simulink Coder is required to run this example.');
returnend

Configure Environment

You must have write-permission to generate the relevant files and the executable. Therefore, before starting simulation and code generation, change the current directory to a temporary directory.