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

2 views (last 30 days)
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

Answers (1)

Rajanya
Rajanya on 11 Feb 2025
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!

Community Treasure Hunt

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

Start Hunting!