Pause and Play button for plotting

조회 수: 10 (최근 30일)
Vick
Vick 2017년 11월 8일
댓글: Vick 2017년 11월 12일
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
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.
Vick
Vick 2017년 11월 12일
Hi,
Thanks for the drawnow function, will help during my program...

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

답변 (0개)

카테고리

Help CenterFile Exchange에서 Graphics Performance에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by