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:|
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.
Define the structure implicitly as a persistent variable in the MATLAB function.
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, on the Simulink Toolstrip, on the Function tab, click Ports & Data Manager and then click
y. The output Type is defined as the