Passing a structure of parameters into and S-function in MATLAB
Mostra commenti meno recenti
I am trying to pass a structure of parameters to an S-function in MATLAB. I have a bunch of parameters and I would like to avoid passing them like this:
% The general form of an MATLAB S-function syntax is: % [SYS,X0,STR,TS,SIMSTATECOMPLIANCE] = SFUNC(T,X,U,FLAG,P1,...,Pn)
I would prefer passing a single structure that includes all of my parameters. I loaded the data into the Model Workspace as:

What should I do now?
Thanks!
Also,I do not want to use global variables.
Risposta accettata
Più risposte (1)
Pavithra Ashok Kumar
il 22 Gen 2016
0 voti
I understand that you want to pass all the parameters as a struct using S-Functions. You can do this by using a "Bus" in the Simulink model. In the S-function builder( Check here for details ), navigate to "Data Properties>Input Ports". In the column "Bus", select "on".This would set the input type as "struct".Hope this helps.
1 Commento
Huck Febbo
il 25 Gen 2016
Categorie
Scopri di più su Block and Blockset Authoring in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!