How to compile a Matlab script using Matlab coder which calls a Simulink model
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Hi,
I created a Simulink model which simulates the energy consumption of a simplified car. The input of the model is a velocity profile and by using basic mechanic formulas is translated into the energy consumption. So input = velocity profile, output = energy profile.
The velocity profile is generated by a m-file (matlab script) based on the target destination to where the car has to drive to. This m-file calls the Simulink model after the velocity profile is generated. After running the Simulink model the script plots the velocity profile together with the energy consumption.
Now my question is: i want to make C-Code from the m-file but after some research on Matlab Central i discovered that its not possible to use the 'sim' command. I found a Matlab question similar to my problem, but the topic was taken offline.
I know i can compile the Simulink model to C (or an executable) using the Simulink coder, which i did. But i don't know the next step, calling the C-code (of the Simulink model) in the original m-script to compile all together with Matlab coder. I also don't understand how the Simulink input (velocity profile) and output (energy profile) is translated into a input and return value in the c-code and how to manipulate them after compilation.
Thanks in advance, Simon
0 comentarios
Respuestas (2)
Arnab De
el 23 de Oct. de 2014
In order to call an external C function from your MATLAB code that you want to use for code generation, you need to use coder.cevel.
0 comentarios
Ver también
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!