i am executing the code below and getting the error"Subscript indices must either be real positive integers or logicals"
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
tina jain
le 18 Mar 2015
Modifié(e) : tina jain
le 19 Mar 2015
function [z]=decalage(y,h)
[s1,s]=size(h);
[p,p]=size(y);
z(1:s-1,1:s-1)=y((p-s+2):p,(p-s+2):p);
z(s:p,s:p)=y(1:(p-s+1),1:(p-s+1));
z(s:p,1:(s-1))=y(1:p-s+1,p-s+2:p);
z(1:s-1,s:p)=y(p-s+2:p,1:p-s+1);
1 commentaire
John D'Errico
le 18 Mar 2015
Please learn to format your code to be readable. It takes only one extra button click, of the "{} Code" button.
Réponse acceptée
John D'Errico
le 18 Mar 2015
My guess is you are creating a zero or negative index. I cannot know where, since I have no idea what are the sizes of your arrays.
YOU however can find this out easily. First of all, the error should tell you what line it happened in. Is there a reason why you did not bother to give us the complete error message? Must we guess?
Finally, you are the one to fix it, since you are the only one who can run your code. (We don't have those arrays.) Learn to use the debugger. It can show you where the error comes from, as well as allow you to see what those variable sizes were when the error occurred.
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Multidimensional Arrays 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!