Switch value in uifigure is inverted

Hi,
The following function taken from https://www.mathworks.com/help/matlab/ref/uiswitch.html doesn't behave as expected in Matlab 2020a
"Switch That Changes Lamp Color"
function lampswitch
fig = uifigure('Position',[100 100 370 280]);
lmp = uilamp(fig,...
'Position',[165 75 20 20],...
'Color','green');
sw = uiswitch(fig,'toggle',...
'Items',{'Go','Stop'},...
'Position',[165 160 20 45],...
'ValueChangedFcn',@switchMoved);
% ValueChangedFcn callback
function switchMoved(src,event)
switch src.Value
case 'Go'
lmp.Color = 'green';
case 'Stop'
lmp.Color = 'red';
end
end
end
The switch value is somehow inverted! Lamp is red when switch is on "Go"(see video here https://www.dropbox.com/s/ms4lrk0x4q88sle/VID_20200704_123830.mp4?dl=0). Sorry for the low quality.

댓글 수: 6

Walter Roberson
Walter Roberson 2020년 7월 4일
I see what you mean in your video...
The code does work properly on my system though.
Roberto De
Roberto De 2020년 7월 4일
I imagined it was something with my machine, but I have no idea what.
Roberto De
Roberto De 2020년 7월 5일
Reinstallaed Matlab and everything went back to normal.
Roberto De
Roberto De 2020년 7월 5일
After receiving an error while working on this app, this weird bug appeared again and now all the switches work in the opposite way. Really frustrating!
Roberto De
Roberto De 2020년 7월 6일
I did further testing: only the uilamps object are affected, other code inside the switch case statements work fine.
Walter Roberson
Walter Roberson 2020년 7월 6일
Strange!

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

답변 (0개)

카테고리

도움말 센터File Exchange에서 Develop Apps Programmatically에 대해 자세히 알아보기

제품

릴리스

R2020a

태그

질문:

2020년 7월 4일

댓글:

2020년 7월 6일

Community Treasure Hunt

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

Start Hunting!

Translated by