Connecting dots with straight line in a loop.
Ältere Kommentare anzeigen
Hi all,
I have a question regarding connecting the dots.
Suppose I have the following sample data points:

I have a while-loop that identifies the first, second, and fourth points in the figure.
I know their index numbers and their (x,y) values.
Pictorially, I would like to connect with a straight line, the aforementioned points.
What is the best way of doing this?
My gut feeling is to input the "draw" code within the while-loop I have so each time I obtain the index of the next point I want to connect, I simply connect to that pictorially. But how to go about this?
Thanks in advance!
Akzeptierte Antwort
Weitere Antworten (2)
darova
am 20 Okt. 2019
Just use plot function
plot(x(index),y(index))
2 Kommentare
Tatte Berklee
am 20 Okt. 2019
darova
am 20 Okt. 2019
If you have data (x,y) and it's order just use plot
x = rand(1,4);
y = rand(1,4);
index = [1 4 2 3];
plot(x(index),y(index))
ABHILASH SINGH
am 20 Okt. 2019
0 Stimmen
Kategorien
Mehr zu Creating and Concatenating Matrices finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!