How to create a C/C++ routine from a Simulink block with the definition of output, input, and parameters in the header?
조회 수: 2 (최근 30일)
이전 댓글 표시
Hello everyone,
The bottom line is that I need to create a Fortran/C/C++ routine from a Simulink block with the definition of output, input, and parameters in the header. In more detail, the case is as follows:
I have a Simulink model that implements structural dynamics as a first-order differential linear system. This model should interface with another dynamics, fluid dynamics, by defining a fluid-structure interaction problem (so closed-loop).
The structural model should receive as input the forces and moments from fluid dynamics, which in turn should receive as input the displacement field from structural dynamics (its output).
However, the integration of the two dynamics must take place at the c++ code level, so my goal is to generate a c++ code of the Simulink model describing the structural dynamics that is able to interface externally with the fluid-dynamics code.
Now, although I am clear on the basic process of generating a Simulink model code, I would like to understand how best to configure the generation process.
Specifically, I would like to understand how to generate a c++ code (or even better, a c++ function) that can properly (and iteratively, so at each call) receive the parameters and inputs from the fluid-dynamics code (forces and moments) and return the structural displacements (thus the structural dynamics outputs) in an externally readable form (from the fluid-dynamics code).
Thank you in advance for the support.
Marco
댓글 수: 5
Benjamin Thompson
2024년 1월 20일
You need to have the Simulink Embedded Coder toolbox to generate "readable" code. There are some helpful videos about the product:
If you have further questions about how to use the source code generated by this tool, attach some very simple models that you have tried yourself. Also attach the source code generated by those simple models if you are able to complete that process and ask further questions about any problems using the source code.
답변 (0개)
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!