フィルターのクリア

error when using min function

10 ビュー (過去 30 日間)
Andrew Poissant
Andrew Poissant 2017 年 2 月 27 日
編集済み: Walter Roberson 2021 年 10 月 31 日
I have a 180x180 matrix of random integers and I am simply trying to find the smallest element but everytime I run the code it says "Index exceeds matrix dimensions." and refers to my last line of code. Any suggestions?
N1 = randi([1,500],45,45);
N2 = randi([25,1000],45,45);
N3 = randi([100,2200],45,45);
N4 = randi([5,700],45,45);
N5 = randi([100,500],45,45);
N6 = randi([800,3500],45,45);
N7 = randi([1000,10000],45,45);
N8 = randi([15,1000],45,45);
N9 = randi([250,900],45,45);
N10 = randi([5000,11000],45,45);
N11 = randi([1750,9000],45,45);
N12 = randi([25,890],45,45);
N13 = randi([2000,7500],45,45);
N14 = randi([200,2300],45,45);
N15 = randi([25,750],45,45);
N16 = randi([50,1323],45,45);
N = [N1 N2 N3 N4;
N5 N6 N7 N8;
N9 N10 N11 N12;
N13 N14 N15 N16];
M = min(N(:))

採用された回答

David Goodmanson
David Goodmanson 2017 年 2 月 27 日
Hi Andrew, this is a hypothetical answer but it may be that you have, somewhere else, defined 'min' to be a variable .e.g min = 4 or similar.
  2 件のコメント
John D'Errico
John D'Errico 2017 年 2 月 27 日
100% on that.
Gökberk Yar
Gökberk Yar 2019 年 11 月 20 日
Thanks a lot, you have just saved my friend's computer vision lab.

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

その他の回答 (1 件)

Pintu Saini
Pintu Saini 2021 年 10 月 31 日
編集済み: Walter Roberson 2021 年 10 月 31 日
If someone uses the min() function inside a matlab function like Histogram normalisation, then also it shows error.
So, error comes if we write this way: min=min(img(:));
To get rid of this, we can do: MIN=min(img(:));
Just don't use the variable name same as that of function name.
Thanks.

カテゴリ

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