How can I avoid function duplication in code generation?
Ältere Kommentare anzeigen
I wrote a corresponding .c and .tlc file for code generation to a Simulink s-function module. However, I found that as I have used the module several times in simulink, the instructions written in the start(block,system) output of the tlc file are repeated in the initialization function of the model.c for code generation. How can I adjust it so that these instructions appear only once?


Antworten (1)
Mark McBroom
am 25 Mär. 2023
0 Stimmen
You need to move your code from the Start() TLC function to the BlockTypeSetup() TLC function. The BlockTypeSetup() TLC function is only called once no matter how many times the S-Function block is used in the model. See here for exxample:
1 Kommentar
yeyuan zhu
am 23 Mai 2023
Kategorien
Mehr zu Target Language Compiler 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!