global variable in a S-function

4 次查看(过去 30 天)
Gustavo
Gustavo 2012-4-24
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

回答(2 个)

Kaustubha Govind
Kaustubha Govind 2012-4-25
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 2012-4-25
I found the error. :)
I had not declared the variables in the .m s-function.
thx.

类别

Help CenterFile Exchange 中查找有关 Block and Blockset Authoring 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by