Pass values from Simulink to referenced model mask

11 views (last 30 days)
Hi,
I have a Simulink system that contains referenced models and I wanted to pass certain values from Simulink in the referenced model using a mask. I have followed the turtorial from Mathworks on how to create the masks for the referenced model and it worked fine for the first referenced model where the value that I passed went to some constant blocks. However, in other referenced model I have a multiport switch which takes as indices some enums and also a random number generator, and I get an error telling me that some parameters are not tunnable. How can I get around this issue?
Thanks,
Radu

Answers (1)

Shivang
Shivang on 27 Sep 2023
Hi Radu,
I understand you're running into an error while working with Model References.
Model references do not allow for non-tunable parameters to be set via model arguments. You can check which parameters of a given block are non-tunable using the workflow described here: https://www.mathworks.com/matlabcentral/answers/1778285-how-can-i-identify-whether-a-block-parameter-is-tunable-or-nontunable-during-simulation
For the Random Number block for example, 'Sample time' is a non-tunable parameter whereas 'Mean', 'Variance' and 'Seed' are not. The error is encountered only when attempting to set the non-tunable parameters.
A workaround for this problem is to use Subsystem References. Refer to the documentation for details on how to work with Subsystem References: https://www.mathworks.com/help/simulink/ug/referenced-subsystem-1.html
Note that subsystem files do not have a model workspace, but you can create a System Mask and define the relevant editable parameters there. After saving the subsystem to a file, you can use it in your model using a Subsystem Reference block.
As a test, I created a simple subsystem consisting of a Random Noise block and an Outport block. The 'Mean' and 'Sample time' of the Random Noise block are defined using parameters 's_mean' and 's_time'. These parameters are also present in the System Mask.
After importing the subsystem into a model using the Subsystem Reference block, I am able to specify both of these parameters and simulate without any problems.
Hope this helps!
-Shivang

Community Treasure Hunt

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

Start Hunting!