Deciding on Simulink method for c++ code generation
Show older comments
I have a large simulation that is run by multiple scripts looping over inputs for multiple Monte Carlo runs. I want to port one algorithm to C++ or C code that will be eventually integrated with the actual hardware system in Linux and we don't expect to need much optimization or have many hardware restrictions. For now we are just trying to prove we can generate accurate, readable, reusable code directly from Matlab using Windows. I need to: 1. Create c++ code for an algorithm that is written as a single matlab function block. 2. Run the generated c++ code from the Simulink model to verify it produces the same output as the original matlab code.
I am not sure if I should be using matlab coder, Simulink coder, S-functions, Embedded Coder or Reference Models with simulink
Using the documentation it seems like Simulink Coder is the correct choice but when I build the subsystem I get an executable, how do I feed that back into the simulation? Do I then need to go create my own mex files to run that c code?
I did find this documentation on verification: but it also lists several methods using all compiler methods https://www.mathworks.com/matlabcentral/answers/99351-how-can-i-compare-results-from-my-simulink-model-to-those-obtained-using-the-code-generation-technol
Which is the best practices method?
I see "legacy" in a lot of the S-function documentation, will this be deprecated soon? Makes me think this is the old style of doing things.
Eventually this will be used by software eng, hardware eng and algorithm developers. Which would be the simplest to automate the code generation and verification so that anyone can maintain it?
If we eventually need more optimization once hardware requirements are known how hard is this to switch to embedded coder? Or should we start with that.
Answers (0)
Categories
Find more on Simulink Coder in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!