How to set default value for instance parameters​/Simulink.​Parameter?

When using a ModelReference block, all instance parameters default to value [], even though they are define using a Simulink.Parameter object with a defined Value field (I expected the Value field to serve as default value for the specified instance parameter).
How can I set a default value for an instance parameter?
Please note that I sometimes want to use the default value, and sometimes don't. If I don't use a default value, I want to be able to programatically define the value of the parameter using this guide: https://de.mathworks.com/help/simulink/ug/parameterize-referenced-models-example.html

답변 (1개)

Mark McBroom
Mark McBroom 2020년 12월 12일

1 개 추천

You will need to configure the parameter as a model argument and then specify values for each isntance of the model block. It is a bit tricky. This link gives step by step instructions.

댓글 수: 3

@Mark McBroom Thanks. So, if I understand this correctly, then unchecking the Argument checkbox should have the desired effect, right?
I did that, and indeed a default value is now used instead of []. However, I need the parameter to be an Argument, because I (sometimes) want to programatically set the value of the parameter using this guide: https://de.mathworks.com/help/simulink/ug/parameterize-referenced-models-example.html
Is there any other way to get this behavior?
I don't think there is a way for a given model to sometimes have the parameter passed as an argument and other times have a default value used.
Thanks.
Mark.
That’s really unfortunate. I’ve been wanting this behavior for some time.

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Simulink Functions에 대해 자세히 알아보기

제품

릴리스

R2020a

질문:

2020년 12월 10일

댓글:

2020년 12월 13일

Community Treasure Hunt

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

Start Hunting!

Translated by