Passing a structure of parameters into and S-function in MATLAB
Ältere Kommentare anzeigen
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.
Akzeptierte Antwort
Weitere Antworten (1)
Pavithra Ashok Kumar
am 22 Jan. 2016
0 Stimmen
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 Kommentar
Huck Febbo
am 25 Jan. 2016
Kategorien
Mehr zu Block and Blockset Authoring finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!