global variable in a S-function

4 views (last 30 days)
Gustavo
Gustavo on 24 Apr 2012
Hi everyone
I'm simulating an partial differential equation (PDE) using the S-function block. When i use numbers in the mask parameters the model work well, but I want to use a global variable from other file to put in the mask parameters and occurs an error. I saw that I can only put numbers in the mask parameters, but I have a time variant parameter. How I can put an value from workspace or a variable with a number in the mask parameter from s-function?
best regards,
Gustavo

Answers (2)

Kaustubha Govind
Kaustubha Govind on 25 Apr 2012
From your description, this seems like the supported workflow. Please specify the error message that you see? Also, please ensure that if you want to tune that parameter (ie, it is time-variant), please ensure that your S-function declares the parameter as tunable using ssSetSFcnParamTunable.
One other thing is that you need to run Ctrl+D or set_param(model, 'SimulationCommand', 'update') every time tunable parameters change in the workspace in order for Simulink to pick up the new value.

Gustavo
Gustavo on 25 Apr 2012
I found the error. :)
I had not declared the variables in the .m s-function.
thx.

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!