필터 지우기
필터 지우기

Delete a plot in GUI rutine

조회 수: 4 (최근 30일)
Gabriel González
Gabriel González 2012년 7월 6일
This is the thing i'm trying to implement a button on a GUI script. The button function is to plot the x,y data over data_1's plot.
data_1 is calculated outside the plot_button callback function
Now the problem is that every time I do click on the plot_button the h2's plot is adding a new plot instead of erase the previous one.
How can i do to erase the previous h2 by just clicking plot_button?
This is an example:
function plot_button_callback()
x=rand(1,100);
y=rand(1,100);
h1=plot(handles.data_1), hold on
h2=plot(x,y)
end

채택된 답변

John
John 2012년 7월 6일
assuming the graph where you are plotting things is called graph_one then follow the example:
cla(handles.graph_one)
plot(handles.graph_one,x,y)
%cla should clear the graph
  댓글 수: 1
Gabriel González
Gabriel González 2012년 7월 7일
Ok. it works. Thanks!

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Honglei Chen
Honglei Chen 2012년 7월 6일
Use
set(h2,'YData',y)
to replace the line.

카테고리

Help CenterFile Exchange에서 Specifying Target for Graphics Output에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by