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 ExchangeCreating, Deleting, and Querying Graphics Objects についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by