Updating GUI plots with Timer

Hi,
i am writing a function to update a GUI axis automatically. The following fuction is sucsessfully called by a timer:
function timerfct (hObject, eventdata, handles)
axes(handles.axes1);
val1 = get(handles.freq1,'value');
val2 = get(handles.freq2,'value');
x=0:0.01:2;
plot(handles.axes1,x,sin(2*pi*val1*x),'r');
%hold (handles.axes1)
%plot(handles.axes1,x,sin(2*pi*val2*x),'b');
%hold (handles.axes1);
%set(handles.text2,'String',num2str(val1))
Without the commented lines the plot is cleared automatically and updated. Now, i want to draw a secound graph in the same axes simultanously.
If i try this with the hold functions in the commented part the two Graphs are cleared and updated. However Matlab opens a new, empty Figure in the background. Why does this happend? I thought im refering only to handles.axes1.
My secound question is, why matlab clears the plot at all before drawing the new graphs with every timer tick? Shouldnt hold prevent this?
Thank you!
Martin

 Respuesta aceptada

per isakson
per isakson el 24 de Mzo. de 2013

0 votos

this command
hold( handles.axes1 )
toggles hold. Try
hold( handles.axes1, 'on' )

Más respuestas (0)

Categorías

Más información sobre Creating, Deleting, and Querying Graphics Objects en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 24 de Mzo. de 2013

Community Treasure Hunt

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

Start Hunting!

Translated by