Turn a Simulink model into a mex file
33 ビュー (過去 30 日間)
古いコメントを表示
Hey!
I'm trying to compare different algorithms and I have most of them in form of MATLAB functions. One of them, however, was given to me in form of a simulink model (don't ask why - I don't understand it either).
I thought what might be possible is to generate C code from the model and turn that into a mex file so that I can use it in Matlab. Calling the simulink model for several thousand times just takes too much time.
The model should have a pure input/output behaviour which means that there are no integrators (or something similar) inside it. In principle, it should be possible to turn this into a simple MATLAB function as it has no states.
I tried generating the code with the Simulink coder and then call
mex model.c
but I get the error:
"rt_logging.h": No such file or directory
Do you have any idea how to solve this problem?
Thanks so much!
0 件のコメント
回答 (1 件)
Salman Ahmed
2021 年 11 月 16 日
Hi Cedric,
The rt_logging.h file is only used if you are logging data to a MAT-file. So it assumes the MAT-file logging option is checked. You can uncheck this option in the model properties of your Simulink model by navigating through Code Generation > Interface > Advanced parameters and uncheck MAT-file logging option.
From what I understand, you wish to convert your Simulink model to MATLAB code. There is no direct method of doing so. If you wish to proceed with mex file creation, you have to do some post processing on the generated C code to include an entry point mexFunction( ). Also, you may need to modify the generated code as it is derived from a deployment perspective.
0 件のコメント
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!