Effacer les filtres
Effacer les filtres

index exceeds matrix dimensions

1 vue (au cours des 30 derniers jours)
sani ars
sani ars le 29 Sep 2012
Commenté : Walter Roberson le 21 Mai 2019
what does this error means??...
"index exceeds matrix dimensions"
  2 commentaires
Matt J
Matt J le 21 Mai 2019
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 le 21 Mai 2019
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.

Connectez-vous pour commenter.

Réponses (1)

Matt J
Matt J le 29 Sep 2012
Modifié(e) : Matt J le 30 Sep 2012
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.

Catégories

En savoir plus sur Matrix Indexing dans Help Center et File Exchange

Tags

Aucun tag saisi pour le moment.

Community Treasure Hunt

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

Start Hunting!

Translated by