pass a parameter to a masked subsystem
4 views (last 30 days)
Show older comments
Hi, I am using Simulink to model a dynamical system.
My system is composed of many subsystem, whose behaviour depends on some parameters (cut-off frequency, amplitude, gain, etc.). All my subsystems are blocks collected in a library.
I would like to set the values of the parameters of the inner blocks inside each subsystem. I am trying to do the following: - Create a mask for each block (done) - Calculate the value of the block parameters depending on the value of the mask parameter (here is where I have got problems).
I supposed that this could be done by creating variables in the initialization tab of the Mask Editor, but I cannot do that.
Any suggestion?
Thank you
0 Comments
Answers (2)
Kaustubha Govind
on 10 Oct 2011
You can set some initial values on the variables from the Initialization pane, but I think the right place for you to put the code might be in the "Dialog Callback" textbox that each parameter has. This will ensure that if the user changes one of the mask parameter values, your dependent variables are also re-calculated.
3 Comments
Kaustubha Govind
on 10 Oct 2011
You're right. Sorry, it looks like the Initialization pane is indeed the right place to create the variables, since it is run at the start of every simulation (so even if the user changes the parameters, that will be account for before simulation starts). Why are you unable to do so?
Doug Eastman
on 10 Oct 2011
Here are two options:
1. Calculate the derived values directly in the blocks that need them in the subsystem. For example, maybe a gain block needs the mass, but all you have is the density and volume, simply enter the gain as 'density*volume'. This is the easiest but may not be the best if you have a complex expression that is used in many blocks in the subsystem.
2. Calculate the value in the initialization pane. E.G. 'mass=density*volume'. Then you can use mass directly in the gain block.
See Also
Categories
Find more on Subsystems in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!