How to interrupt a while loop in Appdesigner by pushing a button?
이전 댓글 표시
I'm using appdesigner in 2016a.I have two buttons. One is for starting a while loop and the other is for stopping that loop.But the old method
set(handles.buttonA, 'UserData', 'stop');
is not working for me. what else can I use in appdesigner? Thanks for answering!
댓글 수: 5
Geoff Hayes
2016년 10월 1일
Victor Lahore's answer moved here
I Have the same problem:
while 1==1
value = app.Iniciar_button.Value
if value == 'off'
break
end
end
But the button value does not refresh
Geoff Hayes
2016년 10월 1일
Victor - try putting a pause or drawnow statement in your while loop (after the if block) so that the loop is interruptible.
Brian
2017년 4월 27일
An interrupt can only occur at one of these commands...
When an object's Interruptible property is set to 'on', its callback can be interrupted at the next occurrence of one of these commands: drawnow, figure, getframe, waitfor, or pause.
I usually set pauses in several places within a function to give the push button interrupt a chance to execute. i.e. pause(.00001)
Lâm Ngô Tùng
2018년 11월 28일
Thank you, Brian.
Bo Sun
2020년 12월 4일
A pause in the loop after if block works very well, that helps a lot. Thanks.
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Create Large-Scale Model Components에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!