Variable Naming in code generation
29 次查看(过去 30 天)
显示 更早的评论
Hi Community,
- I would like to know if there is any possibility of assigning the custom block names to the variables while the code is generated in simulink.
- Also while code is genrated I can see certain variable names are given as rootfile.variableName instead I would like to have rootfile_VariableName.
Any help on this appreciated!
Thanks in advance.
1 个评论
采纳的回答
Fangjun Jiang
2024-1-5
- Take ert.tlc for example, under Code Generation, Identifiers, there are settings that you can change to adjust the Auto-generated identifier naming rules. $N means "Insert name of object (block, signal or signal object, state, parameter, or parameter object) for which identifier is generated."
- rootfile.variableName is a structure, not a variable name. It is created for many of the signals that has default properties and auto storae class. To get rid of it, you need to specify properties and storage classes for all the signals within that structure, and set the naming rule as $R_$N (rootfile_ObjectName)
6 个评论
Fangjun Jiang
2024-1-9
The best way is to select a signal line, right click, select properties, and then give a signal name and create a signal object. By setting the signal object, you can almost control every aspect of the code generation. Without it, the system starts generating signal names according to the tokens and macros mentoned above.
You can apply this export-function model architecture to specify function name, and use the "Ininialize Function" block. https://www.mathworks.com/help/simulink/slref/initializefunction.html
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!