Here is the workflow for creating a structure in a MATLAB Function block:
Decide on the type (or scope) of the structure (see Types of Structures in MATLAB Function Blocks).
Based on the scope, follow these guidelines for creating the structure:
For Structure Scope: | Follow These Steps: |
---|---|
Input |
See Rules for Defining Structures in MATLAB Function Blocks. |
Output |
|
Local | Define the structure implicitly as a local variable in the MATLAB function, as described in Structure Definition for Code Generation. By default, local variables in MATLAB Function blocks are temporary. |
Persistent | Define the structure implicitly as a persistent variable in the MATLAB function. |
Parameter |
|
In this example model, the MATLAB Function block includes MATLAB code that creates a structure. If a MATLAB Function block outputs a structure, then you must use a Simulink.Bus
object to define the bus output.
To see the structure definition, double-click the MATLAB Function block.
Open the Bus Editor and expand the Bus
object definition that represents the structure.
To see how the Bus
object defines the bus output for the MATLAB Function block, in the MATLAB Toolstrip, on the Editor tab, click Edit Data and then click y
. The output Type is defined as the function_bus
Bus
object.