0
すべての列がノードであり、2行おきのすべてがノードであり、それらの間にエッジがある行列からグラフを作成するコードがあります:Matlab: 'cell'型の入力引数が未定義の関数 'digraph'
i=input('How many Subjects we have in the system:');
j=input('How many Objects we have in the system:');
B=randi([0 1], i*2,j);
disp('The Matrix of the system is the following:')
display(B); % Get the system matrix
nNodeCol = size(B,2); % one node for each column of B
nNodeLine = size(B,1)/2; % one node for every two lines of B
% First the column nodes, then the line nodes:
nodeNames = [cellstr(strcat('column', num2str((1:size(B,2))'))) ; cellstr(strcat('line', num2str((1:size(B,1)/2)')))];
% Adjacency matrix adj, adj(i,j)=1 means there is an edge from node#i to node#j:
adj = zeros(nNodeCol+nNodeLine); % square matrix which size is the number of nodes
adj(1:nNodeCol, nNodeCol+1:end) = B(1:2:end,:)'; % edge from a column node to a line node is added for all the 1 in the first line of the node in the matrix
adj(nNodeCol+1:end, 1:nNodeCol) = B(2:2:end,:); % edge from the line node to a column node is added for all the 1 in the second line of the node in the matrix
% Creation of the graph:
G = digraph(adj,nodeNames);
plot(G);
私は私がそれ
Undefined function 'digraph' for input arguments of type 'cell'.
Error in GRAPH (line 23)
G = digraph(adj,nodeNames);
任意の提案得ることはありません。このエラーを取得する実行?ありがとうございました 。
問題は未定義の関数 'digraph'があることです。それは2015bに導入されました。あなたはそれを持っていますか、新しいバージョンですか? –
私は2014aバージョンを持っているので、問題はバージョンだと思いますか? – StamDad
あなたのMATLABがタイムトラベルできるのでなければ、はい!あなたが検索したら、FileExchangeにいくつかの選択肢があります! –