MATLAB Answers

0

How to access masked model parameter from within referenced model

Asked by Kyle Huggins on 20 Dec 2018
Latest activity Commented on by Kyle Huggins on 20 Dec 2018
I have a simulink parent model (A) with a model reference to another model (B), named "B_name" within A, with a mask for a parameter (C).
I have a matlab function block func which needs access to C. How can I programmatically access the masked parameter from within the referenced model?
Attempted solutions:
%peudo code for matlab function inside referenced model B
function func()
p = Simulink.Mask.get(bdroot(gcb));
q = p.getWorkspaceVariables;
Doesn't work because the mask it returns is just the mask object. Not what the parameter was actually changed to.
q = get_param(gcs,'modelworkspace'); %gcs is "B"
q.getVariable('C')
Also doesn't work, it just gives me the default value. Not the masked value. I can get the value of the masked parameter using this:
p = Simulink.Mask.get('A/B_name');
q = p.getWorkspaceVariables;
But the whole point of a model reference & a mask is that it doesn't care who is calling it. So from within func I have no clue what the calling model named the model reference, so I have no idea how to get there. Nor do I appear to know the root name of the calling model.
So i'm either seriously misunderstanding how to use model masks or there is a path forward that i have missed.
Any help is appreciated.

  1 Comment

Figured it out. Check out my answer here

Sign in to comment.

0 Answers