Error using 'graph' function in matlab R2019b

I have created a binarized symmetric matrix A (n x n) which represents the connectivity matrix with 1's and 0's - 1 representing the existence of an edge. This error though is general and works with any type of matrix. When using the command G=graph(A) I get the following error:
>> G=graph(A)
Error using graph.validateEdgeProperties (line 375)
Edge properties must be a table.
Error in graph/set.EdgeProperties (line 330)
G.EdgeProperties = graph.validateEdgeProperties(T);
Error in graph (line 278)
G.EdgeProperties = table(nonzeros(tril(A)), 'VariableNames', {'Weight'});
I am using R2019b. I have not used the graph function before on this version. What is the problem? It occurs irrespective of the matrix that I am using (it is a generic problem).
Thanks!

2 件のコメント

Walter Roberson
Walter Roberson 2019 年 10 月 28 日
What shows up for
which -all table
Elie Matar
Elie Matar 2019 年 10 月 28 日
Hi Walter:
>> which -all table
C:\Program Files\MATLAB\R2019b\toolbox\matlab\datatypes\@table\table.m % table constructor
C:\Program Files\MATLAB\R2019b\toolbox\matlab\bigdata\@tall\table.m % tall method
Thanks!

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

 採用された回答

Christine Tobler
Christine Tobler 2019 年 10 月 29 日

0 投票

Could you try starting a new MATLAB and just enter the following code:
>> A = ones(3);
>> G = graph(A);
If this gives the error message you mentioned, could you again run the following lines on command line?
>> T = table(nonzeros(tril(A)), 'VariableNames', {'Weight'})
>> istable(T)
>> class(T)
If this returns true and 'table', we'll have a deeper mystery to solve. If not, please let us know what is being displayed for you.

5 件のコメント

Elie Matar
Elie Matar 2019 年 10 月 29 日
Hi Christine,
Looks like it returns false for table, but class as Table! Output below... Help appreciated.
T = table(nonzeros(tril(A)), 'VariableNames', {'Weight'})
T =
6×1 table
Weight
______
1
1
1
1
1
1
>> istable(T)
ans =
logical
0
>> class(T)
ans =
'table'
Elie Matar
Elie Matar 2019 年 10 月 29 日
Also just to clarify, it did return the same error message opening a new matlab and the above output relates to the A=ones(3), G=graph(A)
Christine Tobler
Christine Tobler 2019 年 10 月 29 日
Looking at the output from "which -all" you have pasted above, it would seem that this file is the problem:
C:\Program Files\MATLAB\spm12\external\fieldtrip\compat\matlablt2013b\istable.m
The input checking for graph enters that function istable, instead of the standard istable function - and this function returns false when the input is of class 'table'.
You should be able to resolve this by removing that directory, C:\Program Files\MATLAB\spm12\external\fieldtrip\compat\matlablt2013b\ from the MATLAB path (see rmpath).
Elie Matar
Elie Matar 2019 年 10 月 29 日
That solves it! Thankyou very much for your help. Really appreciated.
Ofer Perl
Ofer Perl 2021 年 1 月 31 日
Christine's solution also worked for me, cheers!

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

その他の回答 (1 件)

Steven Lord
Steven Lord 2019 年 10 月 28 日

1 投票

Can you confirm that A is a matrix? What does this show when executed immediately before you try to construct the graph from A?
whos A
If that shows A is a matrix, thinking along the same lines as Walter's idea, do you have your own functions named nonzeros, tril, or istable? Do these commands show versions of these functions other than the ones provided by MATLAB?
which -all nonzeros
which -all tril
which -all istable

3 件のコメント

Elie Matar
Elie Matar 2019 年 10 月 29 日
Hi Steven, thanks for reaching out. Those individual functions all seem to be working. Here is my output below. thanks in advance!
>> which -all nonzeros
built-in (C:\Program Files\MATLAB\R2019b\toolbox\matlab\sparfun\@char\nonzeros) % char method
built-in (C:\Program Files\MATLAB\R2019b\toolbox\matlab\sparfun\@double\nonzeros) % double method
built-in (C:\Program Files\MATLAB\R2019b\toolbox\matlab\sparfun\@int16\nonzeros) % int16 method
built-in (C:\Program Files\MATLAB\R2019b\toolbox\matlab\sparfun\@int32\nonzeros) % int32 method
built-in (C:\Program Files\MATLAB\R2019b\toolbox\matlab\sparfun\@int64\nonzeros) % int64 method
built-in (C:\Program Files\MATLAB\R2019b\toolbox\matlab\sparfun\@int8\nonzeros) % int8 method
built-in (C:\Program Files\MATLAB\R2019b\toolbox\matlab\sparfun\@logical\nonzeros) % logical method
built-in (C:\Program Files\MATLAB\R2019b\toolbox\matlab\sparfun\@single\nonzeros) % single method
built-in (C:\Program Files\MATLAB\R2019b\toolbox\matlab\sparfun\@uint16\nonzeros) % uint16 method
built-in (C:\Program Files\MATLAB\R2019b\toolbox\matlab\sparfun\@uint32\nonzeros) % uint32 method
built-in (C:\Program Files\MATLAB\R2019b\toolbox\matlab\sparfun\@uint64\nonzeros) % uint64 method
built-in (C:\Program Files\MATLAB\R2019b\toolbox\matlab\sparfun\@uint8\nonzeros) % uint8 method
nonzeros is a built-in method % connector.internal.LoggerLevel method
C:\Program Files\MATLAB\R2019b\toolbox\symbolic\symbolic\@sym\nonzeros.m % sym method
C:\Program Files\MATLAB\R2019b\toolbox\symbolic\symbolic\@symfun\nonzeros.m % symfun method
>> which -all tril
built-in (C:\Program Files\MATLAB\R2019b\toolbox\matlab\elmat\@char\tril) % char method
built-in (C:\Program Files\MATLAB\R2019b\toolbox\matlab\elmat\@double\tril) % double method
built-in (C:\Program Files\MATLAB\R2019b\toolbox\matlab\elmat\@int16\tril) % int16 method
built-in (C:\Program Files\MATLAB\R2019b\toolbox\matlab\elmat\@int32\tril) % int32 method
built-in (C:\Program Files\MATLAB\R2019b\toolbox\matlab\elmat\@int64\tril) % int64 method
built-in (C:\Program Files\MATLAB\R2019b\toolbox\matlab\elmat\@int8\tril) % int8 method
built-in (C:\Program Files\MATLAB\R2019b\toolbox\matlab\elmat\@logical\tril) % logical method
built-in (C:\Program Files\MATLAB\R2019b\toolbox\matlab\elmat\@single\tril) % single method
built-in (C:\Program Files\MATLAB\R2019b\toolbox\matlab\elmat\@uint16\tril) % uint16 method
built-in (C:\Program Files\MATLAB\R2019b\toolbox\matlab\elmat\@uint32\tril) % uint32 method
built-in (C:\Program Files\MATLAB\R2019b\toolbox\matlab\elmat\@uint64\tril) % uint64 method
built-in (C:\Program Files\MATLAB\R2019b\toolbox\matlab\elmat\@uint8\tril) % uint8 method
tril is a built-in method % connector.internal.LoggerLevel method
C:\Program Files\MATLAB\R2019b\toolbox\symbolic\symbolic\@sym\tril.m % sym method
>> which -all istable
C:\Program Files\MATLAB\spm12\external\fieldtrip\compat\matlablt2013b\istable.m
C:\Program Files\MATLAB\R2019b\toolbox\matlab\datatypes\istable.m % Shadowed
Steven Lord
Steven Lord 2019 年 10 月 29 日
C:\Program Files\MATLAB\spm12\external\fieldtrip\compat\matlablt2013b\istable.m
This is taking precedence over istable function included in MATLAB. If possible rename it, remove it from the MATLAB path, or delete it altogether.
Elie Matar
Elie Matar 2019 年 10 月 29 日
Yes - thank you very much!

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

製品

リリース

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by