Radio Button Mask for Simscape Block

조회 수: 6 (최근 30일)
Matthew Mishrikey
Matthew Mishrikey 2022년 2월 10일
답변: Matthew Mishrikey 2022년 2월 10일
I have a stock Simscape block (Cauer Element) that has two parameters - Resistance and Tau.
I am trying to add a mask to modify these parameters, but am unsure of how to handle the Callback with the radio buttons.
Depending on which radiobutton selection is made, the underlying resistance and tau get updated with some values. There is also an option to add a custom entry, which enables some custom edit fields.
For the Custom fields, I can enable/disable the edit field container from the command line like this when the Radio Button is set to custom:
h = get_param(gcb,'MaskObject').getDialogControl('ContainerCustom')
h.Enabled = 'off'
So I wish to have the edit container disabled for all radio options except custom.
I also wish to have each radio option update the parameters of the underlying block.
I am not certain how to do these with the radio button element.

채택된 답변

Matthew Mishrikey
Matthew Mishrikey 2022년 2월 10일
I figured out a way. I saw a snippet of code in one of the videos on the topic, and it gave me enough clues to write a callback. Here is the radio button callback in case it helps anyone!
rbc = get_param(gcbh,'HS_Select');
h = get_param(gcbh,'MaskObject').getDialogControl('ContainerCustom');
switch rbc
case 'Sink Vert'
r = '1.6';
t = '1800';
h.Enabled = 'off';
set_param(gcbh,'rthedit',r);
set_param(gcbh,'tauedit',t);
case 'Sink Horiz'
r = '1.3';
t = '1300';
h.Enabled = 'off';
set_param(gcbh,'rthedit',r);
set_param(gcbh,'tauedit',t);
case 'Ideal Heat Sink'
r = '1e-9';
t = '1e-9';
h.Enabled = 'off';
set_param(gcbh,'rthedit',r);
set_param(gcbh,'tauedit',t);
case 'Undersized Heat Sink'
r = '7';
t = '30';
h.Enabled = 'off';
set_param(gcbh,'rthedit',r);
set_param(gcbh,'tauedit',t);
case 'Custom'
h.Enabled = 'on';
end

추가 답변 (0개)

카테고리

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

태그

제품


릴리스

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by