Use the same pushbutton in a GUI as Start and Pause button for an animated loop
이전 댓글 표시
I'm creating a GUI that starts an animation with a pushbutton. I want to:
- start the animation at the first button press - pause the animation at the second button press - resume the animation at the third button press
and so on...
I refresh my plot in the animation is by doing:
for ii:length(X)
set('XData',...,'YData',...)
end
I know how to do this with 2 separate buttons:
function start_button_callback
if get(hObject,'value')
for ii:length(X)
if get(hObject,'value') %checks if changed by pause button
set('XData',...,'YData',...)
....
else
break;
end
end
end
function pause_button_callback
if get(hObject,'Value')
set(handles.start_button,'Value',0);
end
What I want is to use a single pushbutton to start&pause&resume, but I can't get to interrupt the for loop when pushing the start button the second time, even when using a 'handles.counter'. The value of the counter isn't updated at every push button if the loop isn't finished. Any ideas?
댓글 수: 2
Dishant Arora
2013년 7월 25일
Using toggle button instead of a push button would be better in this case.
Oscar
2013년 7월 31일
채택된 답변
추가 답변 (1개)
Jan
2013년 7월 25일
4 개 추천
Did you insert a drawnow to give Matlab the chance to process events?
Did you set the 'Interruptible' property of the button to 'off'?
카테고리
도움말 센터 및 File Exchange에서 Animation에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!