![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1588351/image.png)
How to Compile C code generated by Embedded Coder to run it in S-Function Simulink
조회 수: 4 (최근 30일)
이전 댓글 표시
Dear Community,
I have generated the MPC Controller c code to execute it faster in Simulink Real Time. My code is successfully generated but when I used to compile it using mex function I faced an error and I was unable to find its solution.
My purpose in compiling the c file is to put it into S-Function and execute it in real time because s-function executes faster than MPC Controller simulink block.
I used both Simulink Coder and Embedded Coder for generating codes both gave different errors.
First I will show you files generated by Embedded Coder; my block name was "Subsystem", In the below picture left side shows my all files generated, and command windows show the error while compiling the c file.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1588296/image.png)
After facing a problem in Embedded Coder I generated code using Simulink Coder which also gives me errors.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1588301/image.png)
댓글 수: 0
채택된 답변
Angelo Yeo
2024년 1월 11일
편집: Angelo Yeo
2024년 1월 11일
You can use "S-function Target (rtwsfcn.tlc)" for model or subsystem for code generation. You don't need to re-compile the C code generated via Coder products into s-functions. See the documentation below for further information.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1588351/image.png)
추가 답변 (0개)
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!