How can I change the annotations of a block in Simulink Simscape to reflect the value of the parameter?

7 ビュー (過去 30 日間)
Javier
Javier 2019 年 3 月 27 日
回答済み: Rajanya 2025 年 2 月 11 日 11:57
Hello,
I was wondering how can I show the value of my resistor in the following situation.
I have the following resistor called Rs_EC=10 whose value is stored in workspace variable 1/Soil.Gsoilmax (let's say 10,) I have assiged the R value of such resistor to 1/Soil.Gsoilmax in the block itself, and now I would like to see that value on my simulink model, in other words, the 1/Soil.Gsoilmax show in the below photo should be 10.
How can I achieve this?
Thanks in advance!
Untitled.png

回答 (1 件)

Rajanya
Rajanya 2025 年 2 月 11 日 11:57
You can use a block's 'AttributesFormatString' parameter to display the specified block parameter values below the block - Specify Block Properties.
Following the same, the value 10 was added below the sample resistor block that I used -
set_param(gcb,'AttributesFormatString',sprintf('%s',num2str(expr))) % expr evaluates to 10
Hope this answers your question.
Thanks!

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by