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

조회 수: 1 (최근 30일)
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

채택된 답변

Fangjun Jiang
Fangjun Jiang 2021년 3월 30일
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
Fangjun Jiang
Fangjun Jiang 2021년 3월 31일
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
Wicki Byamba
Wicki Byamba 2021년 4월 8일
okey, it's not optimal but I'll work with that.
Thank you for your assistance :)

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Scopes and Data Logging에 대해 자세히 알아보기

제품


릴리스

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by