How to access masked model parameter from within referenced model
조회 수: 2 (최근 30일)
이전 댓글 표시
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.
답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Author Block Masks에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!