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

2 views (last 30 days)
I would like to be able to have an annotation for a block which displays the name of the block and the value of the parameter which is defined in the base workspace.

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 11 Oct 2023
Edited: MathWorks Support Team on 12 Oct 2023
You would need to edit the 'AttributesFormatString' property of the block to reflect the parameter value. One way to do this would be to place the following code in the 'InitFcn' or 'LoadFcn' of a block. An example to display the value of a Gain block on it is shown.
set_param(gcb,'AttributesFormatString',['= ' num2str(evalin('base',get_param(gcb,'Gain')))])
*For versions earlier than R2006a please use "eval(get_param(gcb,'Gain'))" instead of "evalin".

More Answers (0)

Products

Community Treasure Hunt

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

Start Hunting!