필터 지우기
필터 지우기

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 (최근 30일)
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
SUNANNA S S
SUNANNA S S 2017년 3월 24일
Sir, For eg: A group has six nodes, i.e., a, b, c, d, e, and f .The links of the nodes are ab, ac, ad, ae, ba, bc, bd, bf, be,cd, cf, da, dc, df, ea, ed, ef, and fe. The unique nodes of both followees and followers are a, b, c, d, e, and f . So, I want a 6 by 6 matrix x in which, a is connected to b, c, d, and e; therefore, x12 = x13 = x14 = x15 = 1. By contrast, a is not connected to a and f, therefore x11 = x16 = 0. All the other cells are assigned values using the same method. Thanks

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

답변 (1개)

Jan
Jan 2017년 3월 13일
편집: Jan 2017년 3월 13일
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.
  댓글 수: 1
SUNANNA S S
SUNANNA S S 2017년 3월 24일
Sir, I had tried to get a n by n adjacency matrix in which n denotes the unique number of nodes in the dataset. For eg: A group has six nodes, i.e., a, b, c, d, e, and f .The links of the nodes are ab, ac, ad, ae, ba, bc, bd, bf, be,cd, cf, da, dc, df, ea, ed, ef, and fe. The unique nodes of both followees and followers are a, b, c, d, e, and f . So, I want a 6 by 6 matrix x in which, a is connected to b, c, d, and e; therefore, x12 = x13 = x14 = x15 = 1. By contrast, a is not connected to a and f, therefore x11 = x16 = 0. All the other cells are assigned values using the same method. Thanks

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

카테고리

Help CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

태그

아직 태그를 입력하지 않았습니다.

Community Treasure Hunt

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

Start Hunting!

Translated by