Generate code of function that uses simulink
1 次查看(过去 30 天)
显示 更早的评论
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
0 个评论
回答(1 个)
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.
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!