How to compile a Matlab script using Matlab coder which calls a Simulink model

조회 수: 2 (최근 30일)
Simon
Simon 2014년 10월 8일
답변: Andreas Goser 2015년 3월 9일
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

답변 (2개)

Arnab De
Arnab De 2014년 10월 23일
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.

Andreas Goser
Andreas Goser 2015년 3월 9일
Please have a look at the bug report mentioned in the intitial request that was taken offline.

카테고리

Help CenterFile Exchange에서 Simulink Coder에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by