Turn a Simulink model into a mex file
49 visualizzazioni (ultimi 30 giorni)
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
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!
Salman Ahmed il 16 Nov 2021
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.