How can I use custom storage class for defining global variables in matlab code for code generation?
17 views (last 30 days)
Show older comments
I was able to create my own package of storage class and its application on the simulink model.
Now i want to use the package for matlab coder as i am trying to generate code from matlab code.
How can i approach for this?
1 Comment
Answers (1)
Abhas
on 28 Oct 2024 at 4:42
To use a custom Storage Class in MATLAB, follow these steps:
- Open your Simulink model.
- Go to the C Code tab and click on Code Interface in the Embedded Coder section.
- Select Embedded Coder Dictionary & navigate to Storage Classes.
- Click Add and define the name and properties of your new storage class.
- Now, open Code Mappings via Code Inteface > Code Mappings.
- Select the data elements to customize.
- Choose your custom storage class from the Storage Class dropdown.
You should follow the guidelines for Creating a Storage Class to avoid any issues while creating and configuring:
- Initiate the creation of a storage class and save it using all default settings.
- Ensure that it appears in the code mappings—verify its presence.
- Assign the storage class to the desired object, such as specific Inport(s).
- Begin customizing the newly created storage class.
- If you mistakenly select an incorrect value for a property, the Code Generator will flag errors, helping you identify the root cause more easily. This approach allows you to make incremental customizations while performing code generation.
You may refer to the following documentation link for more details on creating custom Storage Class:
0 Comments
See Also
Categories
Find more on Data and Function Interfaces in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!