Main Content

GenerateMATLABCode from MPC Designer

上面的ic shows how to generate MATLAB®code for creating and simulating model predictive controllers designed in theMPC设计erapp. Generated MATLAB scripts are useful when you want to programmatically reproduce designs that you obtained interactively.

To create a MATLAB script:

  1. In theMPC设计erapp, interactively design and tune your model predictive controller.

  2. On theTuningtab, in theAnalysissection, click theExport Controllerarrow.

    Alternatively, on theMPC设计ertab, in theResult, clickExport Controller.

    Note

    If you openedMPC设计erfrom Simulink®, click theUpdate and Simulatearrow.

  3. UnderExport ControllerorUpdate and Simulate, clickGenerate Script.

  4. In the Generate MATLAB Script dialog box, select one or more simulation scenarios to include in the generated script.

  5. ClickGenerate Scriptto create the MATLAB script for creating the current MPC controller and running the selected simulation scenarios. The generated script opens in the MATLAB Editor.

    In addition to generating a script, the app exports the following to the MATLAB workspace:

    • A copy of the plant used to create the controller, that is the controller internal plant model

    • Copies of the plants used in any simulation scenarios that do not use the default internal plant model

    • The reference and disturbance signals specified for each simulation scenario

See Also

Related Topics