Generate code of function that uses simulink

조회 수: 1 (최근 30일)
Jonas Vervoort
Jonas Vervoort 2014년 5월 8일
답변: Prasanth 2020년 11월 24일
Hi,
I would like to generate a C/C++ function from a matlab function that uses the sim command. Because the sim command is used in a function I had to change the 'SrcWorkspace' to current to be able to use the "FromWorkspace" input block in Simulink.
So my function for example...
function [result] = doSomthing (param1)
param2=2;
param3=3;
t=0.01; % sampletime
t_Final = 10; % stop time
options = simset('SrcWorkspace','current');
sim('Model',[],options);
result = resultX; % resultX comes from the simulink model
end
The problem that I have now is that the '%#codegen' gives warnings on the "unused" variabes param1,param2,... that are only used in the simulink model. Is there a solution to this problem? How can I generate C/C++ code for a matlab function that uses simulink.
Thanks in advance, Kind regards, Jonas

답변 (1개)

Prasanth
Prasanth 2020년 11월 24일
Hi Jonas,
The workflow you are using, i.e., generating C/C++ code for a MATLAB function that calls 'sim' function to simulate a model is not a supported one.
I believe that you are looking how to generate C/C++ code for a Simulink model.
In this case, you should use Simulink Coder to generate C/C++ code from a Simulink model. The following documentation page helps you get started with Simulink Coder.
Hope this helps.

카테고리

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