Passing a structure of parameters into and S-function in MATLAB
Show older comments
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.
Accepted Answer
More Answers (1)
Pavithra Ashok Kumar
on 22 Jan 2016
0 votes
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 Comment
Huck Febbo
on 25 Jan 2016
Categories
Find more on Block and Blockset Authoring in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!