How to Generate C code of Continuous time blocks?

6 次查看(过去 30 天)
Hey Everyone, I want to know how should i generate C code from models that are utilizing continuous time blocks such as transformers?

回答(1 个)

SRance
SRance 2020-11-17
Each Simulink block or MATLAB functions defines whether or not it can be generated to C/C++ code, which can be checked against the general list of MATLAB supported functions for code generation or with each block, listed at the bottom of the help page for that function of block. I.e. even if you wrote a MATLAB function for Simulink, it doens't neccessarily mean the function can be converted to C code.
For C code it is good to avoid continuous states as much as possible so that you can control the discrete time steps of your model when it is deployed to hardware, else you are likely to run into overflow quite quickly.
Use the Debug tab in Simulink to check the discrete and continous parts of your model, noting that for most continuous blocks there is a discrete alternative.
Once your are happy with you model, simply set-up your model to generate code for your specific hardware, noting you will need the Embedded or Simulink coder, or relevant support package for Arduino or Raspberry Pi.

类别

Help CenterFile Exchange 中查找有关 Deployment, Integration, and Supported Hardware 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by