How to get arg min of an N-dimensional Matrix ?

12 ビュー (過去 30 日間)
Rawan hamdi
Rawan hamdi 2013 年 4 月 15 日
回答済み: Steven Lord 2019 年 4 月 30 日
Hi, i'm having an image of size[280,307,191] and i want to get the argmin of it,Any help?

採用された回答

James Tursa
James Tursa 2013 年 4 月 15 日
編集済み: James Tursa 2013 年 4 月 15 日
[m n] = min(M(:));
[x y z] = ind2sub(size(M),n);
x, y, z will be the indexes (i.e., argmin) of the minimum value of your 3D array M.
  2 件のコメント
Rawan hamdi
Rawan hamdi 2013 年 4 月 16 日
thanks but what are the m & n ?
Jan
Jan 2013 年 4 月 16 日
The documentation of min explains this exhaustively already. Type this in Matlab's command window:
help min
doc min
and read it.

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

その他の回答 (3 件)

Cedric
Cedric 2013 年 4 月 15 日
How do you define argmin? If it is the global min, you can get it as follows:
min(M(:))
where M is your 3D array.
  4 件のコメント
Sreeda M A
Sreeda M A 2016 年 7 月 13 日
can you please explain what values should I give for M ??
Andrei Bobrov
Andrei Bobrov 2016 年 7 月 13 日
編集済み: Andrei Bobrov 2016 年 7 月 13 日
Hi Sreeda M A! Example:
M = randi(400,280,307,191);

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


Sean de Wolski
Sean de Wolski 2013 年 4 月 15 日
Or:
min(min(min(M)))
  2 件のコメント
Ties Hendrickx
Ties Hendrickx 2019 年 4 月 29 日
Nope, this will return the minimum value and not the index of the minimum value
Cedric
Cedric 2019 年 4 月 30 日
Just use [~,linIdx] = min(M(:)) and then convert to subscripts using IND2SUB.

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


Steven Lord
Steven Lord 2019 年 4 月 30 日
If you're using release R2019a or later, you probably want to call min with the 'all' dimension input and the 'linear' flag.

Community Treasure Hunt

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

Start Hunting!

Translated by