How can I connect points from different plots

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')

Réponses (1)

KALYAN ACHARJYA
KALYAN ACHARJYA le 13 Mar 2019
Modifié(e) : KALYAN ACHARJYA le 13 Mar 2019
Use the following line at last in the code-
line([x1,x2,x3],[y1,y2,y3],'Color', 'b');

5 commentaires

x1= [2:10:300];
% ^--------^----- are superfluos!
@Madhan ravi Sir I didnot check the code. Thanks for pointing.
Thank you for your help but can I get one line, going through all the different points instead of three seperate straight lines? Like, one line connecting all the points together
KALYAN ACHARJYA
KALYAN ACHARJYA le 13 Mar 2019
Modifié(e) : KALYAN ACHARJYA le 13 Mar 2019
Use the following with different colors
line(x1,y1,'color','y');
line(x2,y2,'color','m');
line(x3,y3,'color','b');
These are still three lines, I'd like one line, zigzagging through all the points, is that possible?

Connectez-vous pour commenter.

Catégories

En savoir plus sur Line Plots dans Centre d'aide et File Exchange

Produits

Version

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by