How can I avoid function duplication in code generation?
조회 수: 1 (최근 30일)
이전 댓글 표시
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?
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1332570/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1332575/image.png)
댓글 수: 0
답변 (1개)
Mark McBroom
2023년 3월 25일
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:
참고 항목
카테고리
Help Center 및 File Exchange에서 Target Language Compiler에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!