i am executing the code below and getting the error"Subscript indices must either be real positive integers or logicals"
1 次查看(过去 30 天)
显示 更早的评论
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 个评论
John D'Errico
2015-3-18
Please learn to format your code to be readable. It takes only one extra button click, of the "{} Code" button.
采纳的回答
John D'Errico
2015-3-18
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 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Multidimensional Arrays 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!