필터 지우기
필터 지우기

index exceeds matrix dimensions

조회 수: 1 (최근 30일)
sani ars
sani ars 2012년 9월 29일
댓글: Walter Roberson 2019년 5월 21일
what does this error means??...
"index exceeds matrix dimensions"
  댓글 수: 2
Matt J
Matt J 2019년 5월 21일
Simon Emery's comment moved here:
Hi, i got the same issue.
I have 3 matrix. the first one is for data vector in matrix [1 2 3 12 11 6 7 8 9 10], the second is for the ii [1 2 3 3 3 7 7 8 9 10] and the last matrix is for the jj (column) [10 2 3 6 8 1 7 3 9 6]
when i creat my function and launch a test with this approach it is work properly... well at least... SOMEONE COULD HELP ME?
afficheMatriceCreuse([1 2 3 12 11 6 7 8 9 10], [1 2 3 3 3 7 7 8 9 10],[10 2 3 6 8 1 7 3 9 6])
i got this error message:
(1,10) 1
(2,2) 2
(3,3) 3
(3,6) 12
(3,8) 11
(7,1) 6
(7,7) 7
(8,3) 8
(9,9) 9
(10,6) 10
Index exceeds matrix dimensions.
Error in afficheMatriceCreuse (line 31)
fprintf('(%i,%i) %i \n', iM(ii),jM(ii),vM(ii))
or Index exceeds matrix dimensions.
Error in afficheMatriceCreuse (line 26)
iM(ii);
Function:
function afficheMatriceCreuse(vM,iM,jM)
for ii = 1:(numel(iM,jM,vM))
(line26) iM(ii);
jM(ii);
vM(ii);
(line31) fprintf('(%i,%i) %i \n', iM(ii),jM(ii),vM(ii))
end
end
Walter Roberson
Walter Roberson 2019년 5월 21일
for ii = 1:(numel(iM,jM,vM))
numel with multiple arguments has undocumented results. It looks to me as if it returns the product of the number of elements of the arguments after the first.
>> numel(1:50,[3 4 5],[3 4; 5 3])
ans =
12
That is, size and content of the first argument was ignored, and the number of elements of the second argument (3) was multipled by the number of elements of the third argument (4) to get the result.

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

답변 (1개)

Matt J
Matt J 2012년 9월 29일
편집: Matt J 2012년 9월 30일
It means you've done something similar to this:
>> x=1:5
x =
1 2 3 4 5
>> y=x(6)
Attempted to access x(6); index out of bounds because numel(x)=5.

카테고리

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