Generate MATLAB Code for Operating Point Configuration
This topic shows how to generate MATLAB® code for operating point configuration using the Steady State Manager or Model Linearizer. You can generate MATLAB code to programmatically reproduce a result that you obtained interactively.
You can also modify the script to compute multiple operating points with systematic variations in operating point specifications (batch computing). For more information, see Batch Compute Steady-State Operating Points Reusing Generated MATLAB Code.
Generate MATLAB Code from Steady State Manager
When computing operating points using the Steady State Manager, you can generate a MATLAB script or a live script for configuring operating point specifications and computing an operating point. To do so:
To create a specification, in the Steady State Manager, on the Steady State tab, click Trim Specification.
In the corresponding specification document, configure the operating point state, input, and output specifications. For an example, see Compute Operating Points from Specifications Using Steady State Manager.
To specify optimization search settings, on the Specification tab, click Trim Options. For more information, see Change Operating Point Search Optimization Settings.
To generate code that creates an operating point using your specifications and search options, click Trim , and select a code generation option.
You can generate one of the following scripts:
Live script — Click
Live Script
.MATLAB script — Click
Script
.
The generated script opens in the MATLAB Editor.
Generate MATLAB Code from Model Linearizer
When computing operating points using the Model Linearizer, you can generate a MATLAB script for configuring operating point specifications and computing an operating point. To do so:
In the Model Linearizer, on the Linear Analysis tab, in the Operating Points drop-down list, click
Trim Model
.In the Trim the model dialog box, on the Specifications tab, configure the operating point state, input, and output specifications. For an example, see Compute Operating Points from Specifications Using Model Linearizer.
In the Options tab, specify search optimization settings. For more information, see Change Operating Point Search Optimization Settings.
To generate code that creates an operating point using your specifications and search options, click Generate MATLAB Script.
The generated code opens in the MATLAB Editor.