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
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Creating, Deleting, and Querying Graphics Objects 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!