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
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
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 件)

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by