Index in position 1 is invalid. Array indices must be positive integers or logical values.
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Purgoufr Purgoufr
le 24 Nov 2020
Modifié(e) : James Tursa
le 24 Nov 2020
kernel = [0 1 0; 1 0 1; 0 1 0]
A = [10 2 10; 10 5 3; 4 2 5]
m = 3;
n = 3;
for i=1:m
for j=1:n
sum = (kernel(m-i,n-j) * A(i-1,j-1))
end
end
Hi everybody,
I got this error ;
Index in position 1 is invalid. Array indices must be positive integers or logical values.
Error in file (line 22)
t = A(x1,x2);
Why I got this error?
0 commentaires
Réponse acceptée
James Tursa
le 24 Nov 2020
Modifié(e) : James Tursa
le 24 Nov 2020
When i=m in your loop you try to access kernel(m-m,n-j) which is kernel(0,m-j), and 0 is an invalid index. Similar problems with all of the other indexing on this line. It is easy to find values of the for-loop indices where each index in your computation is invalid.
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Matrix Indexing dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!