How to use parameter callback to parameterize mask workspace?

1 回表示 (過去 30 日間)
Nicholas Hemenway
Nicholas Hemenway 2024 年 3 月 8 日
編集済み: Paul 2024 年 3 月 9 日
I am struggling to do what I thought would be super simple. I would like to parameterize a subsystem by using the mask work space.
As a super simple example, let's say I have a mask with a single input parameter -- frequency (f) in Hz. In the mask workspace, I would then like to have a derived variable for period -- T = 1/f that I can use throughout my blocks. T should then update anytime f is updated. Of course I could just directly plug in 1/f everywhere I would use T, but this isn't my design intent and doesn't always work when the expression for the derived variable is more complicated.
This seems like a perfect use case for parameter callbacks inside of a mask, but I cannot get it to work, and can't find any examples of anyone doing this online.
Here's my super simple subsystem:
Here's the mask setup with a single parameter:
And here's my attempt at creating a parameter callback:
What am I doing wrong and how do I accomplish this? I'm super surprised there isn't any examples of this in the documentation as parameterizeing a model like this seems like a fairly common use case.
Thanks,
Nick

回答 (1 件)

Paul
Paul 2024 年 3 月 9 日
編集済み: Paul 2024 年 3 月 9 日
What happens if you just enter
T = 1/f;
in the Initialization section and leave the f_callback blank, or delete it altogether?

カテゴリ

Help Center および File ExchangeSubsystems についてさらに検索

タグ

製品


リリース

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by