필터 지우기
필터 지우기

Plotting a figure from a matrix

조회 수: 2 (최근 30일)
Lewis Waswa
Lewis Waswa 2023년 6월 30일
댓글: dpb 2023년 6월 30일
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.

채택된 답변

dpb
dpb 2023년 6월 30일
A=[1 2; 2 3;2 4;3 5; 5 6; 6 7];
G=graph(A(:,1),A(:,2))
G =
graph with properties: Edges: [6×1 table] Nodes: [7×0 table]
plot(G)
  댓글 수: 7
Cris LaPierre
Cris LaPierre 2023년 6월 30일
Node labels have shown up by default since this function was introduced (R2015b)
dpb
dpb 2023년 6월 30일
I would have thought so, too. So wonder what's going on with OP if don't show up for him? Is there a property to turn them on/off?

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Cris LaPierre
Cris LaPierre 2023년 6월 30일
I would use digraph.
A=[1 2; 2 3;2 4;3 5; 5 6; 6 7] ;
G = digraph(A(:,1),A(:,2));
plot(G)

카테고리

Help CenterFile Exchange에서 Environment and Settings에 대해 자세히 알아보기

제품


릴리스

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by