How can I use nested structures in my generated code?

6 views (last 30 days)
How can I use nested structures in my generated code?
I would like to use a few nested structures to capture most of the data used by my model, but Embedded Coder is splitting it into multiple separate variables.

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 18 Jan 2024
Edited: MathWorks Support Team on 29 Feb 2024
The attached files provide two examples of using nested structures in Embedded Coder generated code. Open the "struct_csc_param_init.m" script to see how the nested structures are set up and run it to observe the resulting generated code.
The first example produces a nested structure in the generated code from separate variables in the Base Workspace using the Struct Custom Storage Class.
Here is a link to the MATLAB Documentation describing the "Struct custom storage class"
The second example produces a nested structure in the generated code based on a nested structure in the Base Workspace.
Both example use the "Simulink.Parameter" object as a way to control the format of the generated code.
Please refer to the MATLAB documentation that describes the "Simulink.Parameter" object. To access the release-specific documentation, run the following command in the MATLAB R2018b command window.
web(fullfile(docroot, 'search.html?submitsearch=&qdoc=Simulink.Parameter'))
Please follow the below link to search for the required information regarding the current release:

More Answers (0)

Categories

Find more on Deployment, Integration, and Supported Hardware in Help Center and File Exchange

Products


Release

R2018b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!