Search code examples
cmatlabsimulinkmex

How can I use C generated code from Simulink into a MATLAB script


Here is my problem: We would like to use our different Simulink models within a script in a much faster way than having to open the Simulink environment (our MATLAB script using Simulink is launched many time).

For that purpose, I want to transform the Simulink model into a C version and launch it from a MATLAB script so that the process would be much faster than opening Simulink environment.

Does anyone have already tried this ? Is it possible ? It is unclear to me if I should try to construct an MEX-file from the C code generated with Simulink coder, or if I should use this coder.ceval function to directly run the C code ?


Solution

  • Not sure about the C code approach, but you could generate an executable using the RSIM target. This is relatively easy to implement and should speed up the execution. See Deployment of Simulink Models and Using RSim Target for Batch Simulations for more details.