Finding Object Parameters for controlling Simulink object through "set_param()"

조회 수: 3 (최근 30일)
Jeevan Thomas
Jeevan Thomas 2014년 4월 22일
답변: Rangan M K 2016년 5월 11일
I was looking at controlling (toggling) the "manual switch" block in Simulink through M-scripts (matlab commands).
I was able to do so using the following command:
set_param(gcb, 'sw','0');
set_param(gcb, 'sw','1');
I was able to Google the right parameter (as listed above) in case for manual switch.
Now the question is, from where do I find that manual switch" has a parameter of "sw" to control it using the set_param() function?
I've tried
get_param(gcb, 'DialogParameters')
get_param(gcb, 'ObjectParameters')
Both the above functions doesn't list "sw" as a parameter for "manual switch".
I'm using Simulink on Matlab R2012b

답변 (2개)

Graham Fletcher
Graham Fletcher 2014년 4월 22일
Hi Jeevan,
I think
get(gcbh)
and
set(gcbh, 'sw', '0')
will do what you're after.
HTH, G.
  댓글 수: 1
Jeevan Thomas
Jeevan Thomas 2014년 4월 23일
Hello Graham,
Thank you for your response. Your solution works fine.
But my question is regarding the "sw" argument that you used in
set(gcbh, 'sw', '0')
How do I find that a "Manual Switch" block in Simulink has "sw" attribute?
Tried the following and none of if shows the above "sw" attribute:
get(gcbh)
get_param(gcb, 'DialogParameters')
get_param(gcb, 'ObjectParameters')
Hope my question is clear this time.
Thank you once again.
rgds,
JT

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


Rangan M K
Rangan M K 2016년 5월 11일
Hi Jeevan, I tried get_param(gcb, 'DialogParameters') and get_param(gcb, 'ObjectParameters')
Both of them show a parameter called sw in Matalb2010b. Even the BlockProperies>BlockAnnotations of Mannual Switch shows %<sw> in it.

카테고리

Help CenterFile Exchange에서 Programmatic Model Editing에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by