Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I am working with GUIDE to make a big GUI. I would like to plot two sets of data on the same plot. For regular MATLAB code I would write:

time = 1:10;
data1= (1:10).*2;
data2= (1:10).*3;
figure;
plot(t,data1);
hold on;
plot(t,data2);
hold off;

However, this does not work with the GUI system. With the GUI I am typing:

time = 1:10;
data1= (1:10).*2;
data2= (1:10).*3;
plot(handles.axes1,t,data1);
hold on;
plot(handles.axes1,t,data2);
hold off;

But this does not work. data2 just over writes the previous plot. Any help would be appreciated. Thank you.

SOLUTION:

time = 1:10;
data1= (1:10).*2;
data2= (1:10).*3;
plot(handles.axes1,x,y);
hold(handles.axes1)
plot(handles.axes1,x,z);
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
240 views
Welcome To Ask or Share your Answers For Others

1 Answer

If this is the only thing you want to plot, just use plot functions without axes handle (they will have the same handle by default):

t = 1:10;
data1= (1:10).*2;
data2= (1:10).*3;
plot(t,data1);
hold on;
plot(t,data2);
hold off;

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...