How can I connect points from different plots

5 views (last 30 days)
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
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
KALYAN ACHARJYA
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
Joyce de Heer on 13 Mar 2019
These are still three lines, I'd like one line, zigzagging through all the points, is that possible?

Sign in to comment.

Categories

Find more on Line Plots in Help Center and File Exchange

Products


Release

R2018a

Community Treasure Hunt

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

Start Hunting!