Turn a Simulink model into a mex file

34 次查看(过去 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!

回答(1 个)

Salman Ahmed
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.

类别

Help CenterFile Exchange 中查找有关 Simulink Coder 的更多信息

产品


版本

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by