Turn a Simulink model into a mex file

38 Ansichten (letzte 30 Tage)
Cedric Kotitschke
Cedric Kotitschke am 1 Nov. 2021
Beantwortet: Salman Ahmed am 16 Nov. 2021
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!

Antworten (1)

Salman Ahmed
Salman Ahmed am 16 Nov. 2021
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.

Kategorien

Mehr zu Simulink Coder finden Sie in Help Center und File Exchange

Produkte


Version

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by