accumarray error: Index into matrix must be positive
조회 수: 1 (최근 30일)
이전 댓글 표시
G=[0 1 ; 0 2 ; 1 2];
adj=accumarray(G,1,[],[],0,true);
error: Index into matrix must be positive.
댓글 수: 0
채택된 답변
Star Strider
2016년 4월 4일
What I do in situations such as yours is to add 1 to the minimum value (here 0) of the index array:
G=[0 1 ; 0 2 ; 1 2];
adj=accumarray(G+1,1,[],[],0,true);
That solves the immediate problem. You can make adjustments in other parts of your code afterwards.
댓글 수: 0
추가 답변 (2개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Structures에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!