Create MATLAB structures that use the same hierarchy and attributes as buses
If you use the Simulink.Bus.createMATLABStruct
function
repeatedly for the same model (for example, in a loop in a script), you can
improve performance by avoiding multiple model compilations. For improved speed,
put the model in compile before using the function multiple times. For example,
to put the vdp
model in compile, use this command:
vdp([],[],[],'compile')
After you create the MATLAB structure, terminate the compile by using this command:
vdp([],[],[],'term')
You can use the Bus
Editor to invoke the
Simulink.Bus.createMATLABStruct
function by using one
of these approaches:
Select the File > Create a MATLAB structure menu item.
Select the Bus
object for which you want to create a
full MATLAB structure. Then, in the toolbar, click the
Create a MATLAB structure button .
You can then edit the MATLAB structure in the MATLAB Editor and evaluate the code to create or update the values in this structure.
You can use the Simulink.Bus.createMATLABStruct
function
to specify the initial value of the output of a referenced model. For details,
see the “Referenced Model: Setting Initial Value for Bus Output”
section of the Detailed
Workflow for Managing Data with Model Reference example.