Index exceeds the number of array elements

Hello, matlab shows me this problem:
Index exceeds the number of array elements (495).
Error in Untitled22222 (line 34)
if suma(i)== 0
I mean exactly this loop, I got a little lost and I don't know what to do next.
while 1
if suma(i)== 0
p_kolumna=i;
break;
end
i=i+1;
end
Thank you for your help

10 件のコメント

KSSV
KSSV 2021 年 11 月 12 日
What is suma function?
Awais Saeed
Awais Saeed 2021 年 11 月 12 日
It seems that your condidtion did not meet because of which while loop still runs with an increment of i and i becomes greater than the largest index available.
Blazej Staniak
Blazej Staniak 2021 年 11 月 12 日
ok how should i improve it?
Awais Saeed
Awais Saeed 2021 年 11 月 12 日
if summa(i) is something like 0.000000000000456, the condition will never meet. Use
format long
to see the output
Blazej Staniak
Blazej Staniak 2021 年 11 月 12 日
the same problem
Awais Saeed
Awais Saeed 2021 年 11 月 12 日
what do you mean by the same problem?
Blazej Staniak
Blazej Staniak 2021 年 11 月 12 日
can you contact me? kole99@wp.pl
KSSV
KSSV 2021 年 11 月 12 日
You should share complete code to get help. The variables are not know in the given snippet.
KSSV
KSSV 2021 年 11 月 12 日
What is size of the imahe im1.
im1 = imread('Audi_1.jpg');
Blazej Staniak
Blazej Staniak 2021 年 11 月 12 日
1632x3264x3

サインインしてコメントする。

回答 (2 件)

KSSV
KSSV 2021 年 11 月 12 日

0 投票

Replace the while loop condition:
while 1
with
while i<=length(suma)
It eill not give the error..but still I am surprised what for this while loop is.

4 件のコメント

Blazej Staniak
Blazej Staniak 2021 年 11 月 12 日
yes it is working but i have outher problem...
Unrecognized function or variable 'p_kolumna'.
Error in Untitled (line 38)
im = imcrop(im, [p_kolumna, 1, kolumna, wiersz]);
KSSV
KSSV 2021 年 11 月 12 日
It is becuase p_kolumna is not defined....the suma(i) was never equal to zero. You are missing some logic in your problem.
Blazej Staniak
Blazej Staniak 2021 年 11 月 12 日
p_kolumna is definded in the loop, how to repair?
KSSV
KSSV 2021 年 11 月 15 日
It is defined... But in the while loop suma will never be zero and it will never take the defined value. What is your problem exactly?

サインインしてコメントする。

Blazej Staniak
Blazej Staniak 2021 年 11 月 15 日
編集済み: Blazej Staniak 2021 年 11 月 15 日

0 投票

does anyone know how to solve

カテゴリ

ヘルプ センター および File ExchangeMatrix Indexing についてさらに検索

タグ

質問済み:

2021 年 11 月 12 日

コメント済み:

2021 年 11 月 15 日

Community Treasure Hunt

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

Start Hunting!

Translated by