How can I connect points from different plots
Show older comments
I created three different sets of points on a graph, now I want to connect those points with one line, but I don't know how to do this since they are different sets. Does anyone have an idea?
x1= [2:10:300];
n1=[0:6:179]
y1=[n1];
x2= [4:10:300];
n2=[2:6:179];
y2=[n2];
x3= [6:10:300];
n3 = [2:6:179]
y3=[n3]
plot(x1,y1,'o')
hold on
plot(x2,y2,'o')
plot(x3,y3,'o')
Answers (1)
KALYAN ACHARJYA
on 13 Mar 2019
Edited: KALYAN ACHARJYA
on 13 Mar 2019
Use the following line at last in the code-
line([x1,x2,x3],[y1,y2,y3],'Color', 'b');

5 Comments
madhan ravi
on 13 Mar 2019
x1= [2:10:300];
% ^--------^----- are superfluos!
KALYAN ACHARJYA
on 13 Mar 2019
@Madhan ravi Sir I didnot check the code. Thanks for pointing.
Joyce de Heer
on 13 Mar 2019
KALYAN ACHARJYA
on 13 Mar 2019
Edited: KALYAN ACHARJYA
on 13 Mar 2019
Use the following with different colors
line(x1,y1,'color','y');
line(x2,y2,'color','m');
line(x3,y3,'color','b');
Joyce de Heer
on 13 Mar 2019
Categories
Find more on 2-D and 3-D Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!