Hi Community,
  1. 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.
  2. 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 Kommentar

madhan ravi
madhan ravi am 5 Jan. 2024
Could you post a screenshot of the generated code? Just the important one?

Melden Sie sich an, um zu kommentieren.

 Akzeptierte Antwort

Fangjun Jiang
Fangjun Jiang am 5 Jan. 2024

2 Stimmen

  1. 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."
  2. 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 Kommentare

Alexander
Alexander am 8 Jan. 2024
Is there any way to include the "Unit"-property of a signal in the identifier? Otherwise my workaround would be to include the unit in the signal name which has less integrity in my opinion.
Fangjun Jiang
Fangjun Jiang am 8 Jan. 2024
There is no token for "Unit". "Custom token text" is static and can't be used to reflect "unit".
Alexander
Alexander am 8 Jan. 2024
Thanks for the immediate reply.
So the only way to transfer the physical unit of the signal to the generated code is to include the unit in the signal name, right?
Fangjun Jiang
Fangjun Jiang am 8 Jan. 2024
Yes, AFAIK. There are numerious naming conventions to include abbreviations of unit in the signal name.
Jacob Thomas
Jacob Thomas am 9 Jan. 2024
May i know, if there is an options,
  1. to change the inport and outport name in the generated code. right now its coming as X and Y respectively. instead i would like to make those as the blocknames.
  2. in the genrated code what does a block and signal has the impact. My idea is like variable names are the blocks like constants, inport, outport and the signals are pointers or a variable reference to a function?
  3. generated code has intialize, step.. fucntions is there any way i could change the name of those
Fangjun Jiang
Fangjun Jiang am 9 Jan. 2024
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

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Simulink Coder finden Sie in Hilfe-Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by