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

 채택된 답변

per isakson
per isakson 2013년 3월 24일

0 개 추천

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

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Creating, Deleting, and Querying Graphics Objects에 대해 자세히 알아보기

태그

질문:

2013년 3월 24일

Community Treasure Hunt

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

Start Hunting!

Translated by