Simulink Code Generator - Preserve User Names
1 view (last 30 days)
Show older comments
Using Version 2018b, is there a way to use the "Preserve User Names" for "code" in a MATLAB function (as the help indicates is in the MATLAB encoder for code generation)?
Looking at the code generated out of the Simulink Code generation, I can see that it makes decisions on removing locally declared variables. These have been added to avoid repeating calculations throughout the script therefore reducing the number of function calls required. However, when these are optimised in code generation, the labels are used in a different order meaning the code is now misleading . Now this could be fixed by not using meaningful names in the Matlab function script in the first place, but that's not acceptable really. When I have to debug this code, I want to be able to read it as intended.
0 Comments
Answers (1)
Meghna Chatterjee
on 14 Apr 2021
Hi Simon,
To control the names of the structures in the generated code, you need an Embedded Coder® license. To instead store a data item in a separate global variable whose name, file placement, and other characteristics you can control, you can apply a storage class to a signal, state, or Simulink.Parameter object. See C Code Generation Configuration for Model Interface Elements and Configuring Data Accessibility for additional explanation and steps.
See Also
Categories
Find more on Simulink Coder 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!