error in digraph while finding adjacency matrix

9 ビュー (過去 30 日間)
Deepa Barathy
Deepa Barathy 2018 年 10 月 9 日
コメント済み: Deepa Barathy 2018 年 10 月 9 日
i get this error while finding adjacency matrix Error using digraph/adjacency Too many input arguments. hers the simple code s = [1 2 5 7 1 3 6 8 2 4 3 4 6];
t = [2 5 7 9 3 6 8 9 4 6 4 5 7];
W=[1 2 3 4 1 2 3 4 2 3 2 3 3];
names = {'S' 'A' 'B' 'C' 'E' 'F' 'G' 'H' 'D'};
G = digraph(s,t,W,names);
A=adjacency(G,'weights')
s=plot(G,'layout','force','Edgelabel',G.Edges.Weight);
B = full(A)

回答 (2 件)

Guillaume
Guillaume 2018 年 10 月 9 日
編集済み: Guillaume 2018 年 10 月 9 日
The optional second input argument of adjacency was introduced in R2018a. Since you get a too many input arguments error when giving a second input we can safely conclude that you're using an earlier version.
You should look at the documentation that comes with your version.
doc digraph.adjacency
at matlab command prompt to look at your documentation.
Note that the proper syntax in R2018a or later is
adjacency(G,'weighted') %not 'weights'
  1 件のコメント
Deepa Barathy
Deepa Barathy 2018 年 10 月 9 日
Thank u so much..mine is 17b

サインインしてコメントする。


Stephan
Stephan 2018 年 10 月 9 日
Hi,
try:
s = [1 2 5 7 1 3 6 8 2 4 3 4 6];
t = [2 5 7 9 3 6 8 9 4 6 4 5 7];
W=[1 2 3 4 1 2 3 4 2 3 2 3 3];
names = {'S' 'A' 'B' 'C' 'E' 'F' 'G' 'H' 'D'};
G = digraph(s,t,W,names);
A=adjacency(G,W)
s=plot(G,'layout','force','Edgelabel',G.Edges.Weight);
B = full(A)
Best regards
Stephan
  1 件のコメント
Deepa Barathy
Deepa Barathy 2018 年 10 月 9 日
thank you so much for replying Mr.Stephan..But still I get the same Error
"Error using digraph/adjacency Too many input arguments.
Error in grapp (line 6) A=adjacency(G,W)

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeGraph and Network Algorithms についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by