How do I programmatically add inputs to a matlab function block ?
19 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Hi I am creating a utility-function that creates a model with a Matlab-function-block, which content is derived from our internal-developed datadictionary. I figured out how to change the Matlab-code itself via Stateflow.EMChart, but I cant find a solution on how to change the number of inputs (in my case number of outputs is always 1). Does anybody has some experience to share here?
Kind Regards Erik Voigt
0 Commenti
Risposta accettata
Nirja Mehta
il 1 Dic 2016
I am assuming you are working on a newer release of MATLAB, but the following links explain how you can programmatically change the number of inputs of your MATLAB function block (which was called Embedded MATLAB Function block in older releases): https://www.mathworks.com/matlabcentral/answers/100659-how-do-i-set-user-defined-parameters-in-an-embedded-matlab-function-block-from-the-matlab-command-pr
Essentially, you need to get the handle of the Stateflow.EMChart object that you already have handy by executing the following command:
>> B = S.find('Name','myBlockName','-isa','Stateflow.EMChart');
You would then be able to add extra inputs to the Embedded MATLAB Function block as explained in Step 2. To do this execute the following commands at the MATLAB prompt:
>> line1='function y = fcn(u,param1,param2)';
>> line2=' y = u*param1*param2;';
>> B.Script = line1;
>> B.Script = line2;
1 Commento
Più risposte (1)
Igal
il 19 Giu 2018
Hi All,
Is there any way I can programatically set output sizes as well and not only data types? i can't find anyting about it in documentation.
Thanks.
0 Commenti
Vedere anche
Categorie
Scopri di più su Simulink Environment Customization in Help Center e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!