Plotting a figure from a matrix
Show older comments
I have the following matrix, which describe the connection between nodes on a network. How can I plot this in Matlab?
A=[1 2; 2 3;2 4;3 5; 5 6; 6 7]
The node 1 is connected to 2, the node 2 is conncted to 3 and 4, node 3 is connected to node 5, which is conncted to 6, which is conncted to 7.
How can I plot this in matlab?
Thank you.
Accepted Answer
More Answers (1)
A=[1 2; 2 3;2 4;3 5; 5 6; 6 7] ;
G = digraph(A(:,1),A(:,2));
plot(G)
1 Comment
Lewis Waswa
on 30 Jun 2023
Categories
Find more on Graph and Network Algorithms in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
