How to put variable name in Y-limits of a scope in Simulink programmatically from Matlab

I want to put variables names in the Y-limits of a scope in Simulink( v10) with Matlab (v2019b). To be able to control the Y-limits of my scopes with variables associated to the thing i'm measuring.
I can do it with the GUI via the Y-limits (minimum) and Y-limits (maximum) but the value stored in Y-limits (when i do "get_param(path,'scopeconfiguration')") is the vector with the numerical value.
But when I try to do it programmaticall, I can't put variable names. As it only accept 2-element finite numeric vector.
Thanks in advance
Byamba

 Accepted Answer

Seems true but also, it works this way.
>> YY=5
YY =
5
>> set(gcbh,'ActiveDisplayYMaximum','YY')
>> get(gcbh,'ActiveDisplayYMaximum')
ans =
'5'
>> YY=3
YY =
3
>> set(gcbh,'ActiveDisplayYMaximum','YY')
>> get(gcbh,'ActiveDisplayYMaximum')
ans =
'3'

3 Comments

Thank you for your answer. I did't knwo that you could use the parameter 'ActiveDisplayYMaximum' can I ask you where did you find this parameter ? (When searching i didn't find anything)
But what I would like to do is that the parameter 'YY' is written in the parameter.
When I use "get(gcbh,'ActiveDisplayYMaximum')" it would return 'YY' not the value of the variable 'YY'.
When I write manually 'YY' in the parameter of the scope and use "get(gcbh,'ActiveDisplayYMaximum')", I get the parameter 'YY'.
but when I use "set(gcbh,'ActiveDisplayYMaximum','YY')" it writes the value of 'YY' not the name 'YY'
Let's assume YY=2. You can type in "YY" in the block parameter dialog window of the Scope block and click "Ok" or "Apply". The "YY" stays there but if you then run get(gcbh,'ActiveDisplayYMaximum'), you will get '2'.
Run "YY=1;get(gcbh,'ActiveDisplayYMaximum')", you will get "1".
Run "YY=3;get(gcbh,'ActiveDisplayYMaximum')", you will get "3".
Not sure why this happens. Probably can dig further to see where "YY" is saved at. But I hope this provide you with a workable solution. Either
  1. Manually set "YY" in the Scope block, then change the value of "YY" as needed.
  2. Whenever need to change the value of "YY", run set() command
okey, it's not optimal but I'll work with that.
Thank you for your assistance :)

Sign in to comment.

More Answers (0)

Products

Release

R2019b

Community Treasure Hunt

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

Start Hunting!