Clear Filters
Clear Filters

Is there an easy way to get Embedded Coder to use Simulink signal names in C code?

12 views (last 30 days)
I have a model named "GC" and I want Embedded Coder to use the signal names I defined in Simulink in the generated C code. I set the Code Generation Identifiers for global and local variables, types, field names, etc. to 'GC_$N$M'. Now if I have a Simulink signal named "TestSignal", I'd expect to find it in the code as something like "GC_TestSignal", however everything I can find in my generated code are ouput names of subsystems or stuff like "GC_Multiply4"...
I found a solution here: How can I tell Simulink Embedded Coder to get its variable names from my signal names, not the source block names? - (mathworks.com), but thats a lot of work to do, if you have a finished model with thousands of signals. Long story short: Is there a easier war to tell Embedded Coder to use my signal names or am I missing something here?

Answers (1)

Kausthub
Kausthub on 13 Oct 2023
Hi Matthias Em,
I understand that you have set the Code Generation Identifiers to “GC_$N$M” and would like to have variables names with format “GC_TestSignal” in the generated C code.
The “$N” in “GC_$N$M” refers to the name of the object (block, signal or signal object, state, parameter or parameter object) being identified and in most cases by default “$N” would be the name of the signal itself. However, if the signal name is not provided, "$N" would be the name of the block.
The reason why the name “GC_Multiply4” is being generated is because the signal name is not provided and “$N” in this case would be the name of the block, which is “Multiply”.
Please note that if you are only changing the names of signals and blocks, the code will not be updated after code generation. This is because no structural, parameter, or code replacement library changes would be detected. To reflect the new names, please delete the previously generated code and try generating the code again.
For more information, you can refer to the following documentation pages:
I hope this explanation helps and resolves your query about using signal names for variables while generating C code using Embedder Coder.

Products


Release

R2018b

Community Treasure Hunt

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

Start Hunting!