I want to access an excel file with 500 by 2 matrix and check the connected nodes(bidirectional) in that matrix and the output will be a matrix with 1 represent connection otherwise 0.When I run this code,the error is"Maximum variable size exceeded"
1 view (last 30 days)
Show older comments
clc;
A = csvread('twitnet');
numnode = max(A(:));
adj = zeros(numnode,numnode);
fromlist = A(:,1);
tolist = A(:,2);
fromtoidx = sub2ind([numnode,numnode], fromlist, tolist);
adj(fromtoidx) = 1;
tofromidx = sub2ind([numnode,numnode], tolist, fromlist);
adj(tofromidx) = 1;
5 Comments
Guillaume
on 24 Mar 2017
See also i-am-a-beginner-in-matlab-so-could-anyone-please-help-me-to-create-an-adjacency-matrix-based-on-th which seems to be the same question as this.
Answers (1)
Jan
on 13 Mar 2017
Edited: Jan
on 13 Mar 2017
The values in tolist and fromlist are larger than the length of the input numnode. The file has 1000 rows, but only the first 500 are populated. Then using e.g. the indices 1937235 and 2589158 must fail.
We cannot guess, what you want to achieve based on the failing code only. So please edit the question and add more details.
See Also
Categories
Find more on Environment and Settings in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!