Plotting points and lines
8 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I have two arrays, one with points, and one of members saying which points they wish to connect. Below is the data. So essentially there is supposed to be points at (node_x,node_y). Then I would like to connect those points with 21 members ie size(member_nodes). For example, the first member should connect nodes 2 and 3 which are at points (0,0) and (5,0) respectively. Also if possible, it would be optimal to label what member/node is what on the plot. Thanks in advance, I realize this is a bit complicated.
node_x = [15.0, 0.0, 5.0, 10.0, 15.0, 20.0, 25.0, 30.0, 5.0, 10.0, 20.0, 25.0].';
node_y = [5.0 , 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 5.0, 5.0, 5.0, 5.0].';
member_nodes = [2, 3;
3, 4;
4, 5;
5, 6;
6, 7;
7, 8;
2, 9
3, 9;
3, 10;
4, 10;
4, 1;
5, 1;
1, 6;
6, 11;
11, 7;
7, 12;
12, 8;
9, 10;
10, 1;
1, 11;
11, 12];
0 Kommentare
Akzeptierte Antwort
Walter Roberson
am 23 Apr. 2012
x_coords = [node_x(member_nodes), NaN(size(member_nodes,1),1)];
y_coords = [node_y(member_nodes), NaN(size(member_nodes,1),1)];
plot(x_coords(:), y_coords(:))
8 Kommentare
Walter Roberson
am 25 Apr. 2012
Sorry I glanced at this at work but didn't see anything obvious. I do not have access to MATLAB from home.
Walter Roberson
am 25 Apr. 2012
alex, it looks like gplot() would help you.
http://www.mathworks.com/help/techdoc/ref/gplot.html
In your case, the adjacency matrix would be
accumarray(member_nodes, 1)
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Line Plots finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!