Here is the code that I'm trying to rename graph nodes as a,b,c in output. But it shows error
a=[1 2 3];
b=[3 2 1];
g=graph(a,b);
p=plot(g);
c=[a b c];
p.NodeLabel=[c];

 채택된 답변

KSSV
KSSV 2021년 12월 23일

1 개 추천

a=[1 2 3];
b=[3 2 1];
g=graph(a,b);
p=plot(g);
L={'a' 'b' 'c'};
p.NodeLabel=L;

추가 답변 (1개)

Shanmugavelan S
Shanmugavelan S 2021년 12월 24일

0 개 추천

Thank you sir. Suppose if we have n nodes, how to rename . This code works fine if vertex set is small. How to rename for a graph with n nodes(say)1:n as {2,4,6,... 2n} like that

댓글 수: 1

B = bucky;
g = graph(B(1:20, 1:20));
h = plot(g);
figure
h2 = plot(g);
h2.NodeLabel = string(2:2:40); % or
figure
h3 = plot(g);
h3.NodeLabel = "a" + (1:20);

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

카테고리

도움말 센터File Exchange에서 Line Plots에 대해 자세히 알아보기

제품

릴리스

R2021a

질문:

2021년 12월 23일

댓글:

2021년 12월 24일

Community Treasure Hunt

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

Start Hunting!

Translated by