Generate code of function that uses simulink
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Réponses (1)
Prasanth
le 24 Nov 2020
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 commentaires
Voir également
Catégories
En savoir plus sur MATLAB Coder dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!