MATLAB Answers

Passing different parameters into multiple referenced models in Simulink

5 views (last 30 days)
Jason Baxter
Jason Baxter on 6 Nov 2014
Commented: Torsten Knodt on 10 Nov 2014
Inside Simulink, I have a model of a sensor. A larger system contains several of these sensors, each sensor is functionally the same but needs to have different parameters put into each one.
I have tried to do this by creating variables with a script in the matlab workspace for example:
sensor1.bias = 1; sensor1.scaleFactor = 2; sensor2.bias = 3; sensor2.scaleFactor = 4; etc creating a structure.
I then created a Mask for the first referenced model for each instance with the property name 'sensor' and property value 'sensor1' and for the second referenced model property name 'sensor' and property value 'sensor2'. The idea of this is to pass the correct values through.
The variable names inside the sensor are sensor.bias and sensor.scaleFactor. The idea is that a different structure is fed into each referenced model but it doesn't work! I get the following error:
Invalid setting in 'refTest/Constant' for parameter 'Value'
Error evaluating parameter 'Value' in 'refTest/Constant'
Undefined variable "sensor" or class "sensor.bias".
This seems like the most logical way to pass variables through since i have around 50 different parameters for each sensor. Why doesn't this work? I would appretiate any help! thank you

  1 Comment

Torsten Knodt
Torsten Knodt on 10 Nov 2014
Referenced models only have their own workspace, as far as I know. For referenced models I create the parameter in the referenced model workspace and list them in the "model arguments". Then you can pass them in the properties dialog of the model reference. If you want a mask on this, AFAIK you have to create a library which references the model block and covers it by a mask you can later configure. At least this is the way I do it. For non-tunable parameters I usually use own linked library blocks. Based on the parameter names I guess this is a more suitable solution.

Sign in to comment.

Answers (0)

Sign in to answer this question.