Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you draw a line between points in matlab?

I'm looking to create a "web" between a set of points where the data tells whether there is a link between any two points.

The way I thought of would be by plotting every couple points, and overlaying each couple on top of eachother.

However, if there is a way to just simple draw a line between two points that would be much easier.

Any help would be appreciated!

like image 775
Sind Avatar asked Apr 01 '11 15:04

Sind


1 Answers

If you can organize the x and y coordinates of your line segments into 2-by-N arrays, you can use the function PLOT to plot each column of the matrices as a line. Here's a simple example to draw the four lines of a unit square:

x = [0 1 1 0; ...
     1 1 0 0];
y = [0 0 1 1; ...
     0 1 1 0];
plot(x,y);

This will plot each line in a different color. To plot all of the lines as black, do this:

plot(x,y,'k');
like image 85
gnovice Avatar answered Sep 18 '22 14:09

gnovice