Is there a way to generate a C Source Mex file out of a Simulink model?

4 visualizaciones (últimos 30 días)
I am able to create a s-Function of my Simulink model with the help of the Simulink Coder.
But: I need to build a C Mex file of that Simulink model.
The example: My aim is to model a plant and a controller in Simulink. The controller is a model based controller and inhabits a discrete model of the plant, called model_p. Now this model_p should be a C Mex file for computation times sake. The controller is supposed to be a Matlab-Function or a s-Function with a sample time of let's say Ts=0.1s. So every timestep n*Ts the controller's output is a new control value for the plant. And every timestep the controller calls the model_p within its function to calculate several variations of the next control value and determine the best next control value by searching for the best suited output of the model_p. If interessted, look for particle swarm optimization.
Back to my problem: I do not know how to call the model_p other than as a function. Therefore I need this model_p to be C Mex file. Is there a way to generate a C Source Mex file out of a Simulink model?

Respuestas (1)

Archit Dhanani
Archit Dhanani el 29 de Jul. de 2019
writing a tlc file for the SFunction will assist in code generation. You can read the discussion on the page below:

Categorías

Más información sobre Simulink Coder en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by