Pause and Play button for plotting
8 次查看(过去 30 天)
显示 更早的评论
Hi,
I'm having a data(ydata) of size 2000*2000, which has to be plotted in an axes one by one (given delay time as 0.5 sec) in gui axes when the user press the push button or toggle button(Play), the same has to be paused when it is pressed again(pause), How can it be done in a simplest way.
My current logic is,
ydata=rand(2000,2000);xdata=1:size(ydata,1); %random data
for i=handles.old_pause_data:size(ydata,2)
delay=str2num(get(handles.delaytime,'String')); % getting delay time from the edit text box
if get(handles.play_button,'Value')==1 % check to pause or play
plot(handles.axes1,xdata,ydata(:,i)) % plot the data
pause(delay) % delay for the given time
else
handles.old_pause_data=i; % save the pasued value.
break
end
end
guidata(hObject,handles)
The above code is bit complicated, I thought like it can be done easily.
Also I would like to change the toggle button to Play and Pause icon.
2 个评论
Rik
2017-11-8
Changing the icon should be done in the callback of the button itself. The code you have is not overly complicated, although correctly aligning it (in Matlab) will help. Be aware that sometimes you will need to call drawnow to execute queued button callbacks. If the pause is long enough (which it generally is), an extra drawnow is not needed.
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Environment and Settings 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!