Passing a structure of parameters into and S-function in MATLAB
Afficher commentaires plus anciens
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.
Réponse acceptée
Plus de réponses (1)
Pavithra Ashok Kumar
le 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 commentaire
Huck Febbo
le 25 Jan 2016
Catégories
En savoir plus sur Block and Blockset Authoring dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!