Pause and Play button for plotting

17 visualizaciones (últimos 30 días)
Vick
Vick el 8 de Nov. de 2017
Comentada: Vick el 12 de Nov. de 2017
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 comentarios
Rik
Rik el 8 de Nov. de 2017
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 el 12 de Nov. de 2017
Hi,
Thanks for the drawnow function, will help during my program...

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre Graphics Performance en Help Center y File Exchange.

Etiquetas

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by