Array indices must be positive integers or logical values. with max values?

1 回表示 (過去 30 日間)
Alberto Paniate
Alberto Paniate 2021 年 11 月 2 日
コメント済み: Matt J 2021 年 11 月 2 日
Hi, today I have found an error that, using the same code, I haven't found before.
I have a 3D matrix CCC (20x20x3000).
for example (20x20x1) is the one below.
Now I want to find the max value of the matrix doing: max(max(CCC(:,:,1))) and I obtain:
Array indices must be positive integers or logical values.
why?

採用された回答

Matt J
Matt J 2021 年 11 月 2 日
編集済み: Matt J 2021 年 11 月 2 日
Probably because you created a variable named "max" earlier in the code, which is now shadowing the max() function.
Incidentally, a better way to find the max over an array is max(CCC(:)) or in recent Matlab max(CCC,[],'all'). These work independently of the dimension of the array, and are more efficient because you only call max() one time.
  2 件のコメント
Alberto Paniate
Alberto Paniate 2021 年 11 月 2 日
Yes, that was the problem. Thank you
Matt J
Matt J 2021 年 11 月 2 日
You're welcome, but please Accept-click the answer to indicate that it resolved your question.

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

その他の回答 (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