Can't pass parameters from a mask to a subsystem

37 Ansichten (letzte 30 Tage)
Matt Garrett
Matt Garrett am 25 Apr. 2011
I've got a subsystem model with a Constant block whose constant value is "m".
I masked the subsystem and on the parameters tab I added a line with the following items:
#: 1, Prompt: multiplier, Variable: m, Type: edit, ...
In my top model I added a reference to the masked subsystem model. Within the top model I double-clicked on the masked model and entered a value for "m" on the "Model Reference (mask)" dialog.
But when I run the model, it tells me that m is undefined in the subsystem model. I tried creating a new variable called m in the Matlab workspace and re-running the model. That worked. So I can pass a parameter value from the Matlab workspace to my subsystem model but not from the subsystem mask. What am I doing wrong with the mask?
Thanks in advance for helping. Matt
  2 Kommentare
Arnaud Miege
Arnaud Miege am 26 Apr. 2011
It should work, so you must be doing something wrong. Could you upload your model to a filesharing site?
Matt Garrett
Matt Garrett am 26 Apr. 2011
Thanks Arnaud, but I managed to figure it out based on Jarrod's response below.

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Jarrod Rivituso
Jarrod Rivituso am 26 Apr. 2011
Are you masking a Model block, or a subsystem?
It sounds like you added a mask to a subsystem in your top description. However, the "Model Reference (mask)" dialog makes it sounds like you are entering the parameter in a Model block mask.
Passing parameters into a Model Reference requires that you add the parameter to the model's Model Workspace (View -> Model Explorer) and then designate the variable as a parameter in the "Model Arguments" list. Then you can mask the Model block, and override parameters.
So, in summary
  1. Add m to the model's model workspace
  2. Write "m" in the Model Arguments option (found in the model worksapce)
  3. In the particular instance of the Model block, right-click and select Model Reference parameters, and then put "m" in the Model Arguments.
  4. Mask the Model block the way you have done.
Give that a try and let us know if you have any more problems.
  2 Kommentare
Matt Garrett
Matt Garrett am 26 Apr. 2011
Hi Jarrod,
Thank you for your help. Yes, I was masking a Model block. To use my obviously inaccurate terminology, my "subsystem" was a pre-existing mdl file. The only way I could figure out how to include it in my higher-level model was with a model reference, but it sounds like there might be a simpler way...?
Thank you again for your detailed and accurate diagnosis.
Matt Garrett
ATA Engineering
Golden, CO, USA
Radu Nicolae Rotaru
Radu Nicolae Rotaru am 15 Jul. 2022
Hi,
I know it's been more than 10 years since you answered this question but I thought I will give it a try. I did exactly what you said and it worked flawlessly for the 'm' example in a constant block. However my referenced model uses Multiport Switches and Random Number Generators which take in variable inputs. If I try to input those 'm' variables defined in the model workspace I get the error:
Any suggestions on how to solve this?

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Subsystems finden Sie in Help Center und File Exchange

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by