How can I use custom storage class for defining global variables in matlab code for code generation?

3 次查看(过去 30 天)
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 个)

Abhas
Abhas 2024-10-28
To use a custom Storage Class in MATLAB, follow these steps:
  1. Open your Simulink model.
  2. Go to the C Code tab and click on Code Interface in the Embedded Coder section.
  3. Select Embedded Coder Dictionary & navigate to Storage Classes.
  4. Click Add and define the name and properties of your new storage class.
  5. Now, open Code Mappings via Code Inteface > Code Mappings.
  6. Select the data elements to customize.
  7. 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:
  1. Initiate the creation of a storage class and save it using all default settings.
  2. Ensure that it appears in the code mappings—verify its presence.
  3. Assign the storage class to the desired object, such as specific Inport(s).
  4. Begin customizing the newly created storage class.
  5. 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:

类别

Help CenterFile Exchange 中查找有关 Data and Function Interfaces 的更多信息

产品


版本

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by