Filter löschen
Filter löschen

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

16 Ansichten (letzte 30 Tage)
Rawan hamdi
Rawan hamdi am 15 Apr. 2013
Beantwortet: Steven Lord am 30 Apr. 2019
Hi, i'm having an image of size[280,307,191] and i want to get the argmin of it,Any help?

Akzeptierte Antwort

James Tursa
James Tursa am 15 Apr. 2013
Bearbeitet: James Tursa am 15 Apr. 2013
[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 Kommentare
Rawan hamdi
Rawan hamdi am 16 Apr. 2013
thanks but what are the m & n ?
Jan
Jan am 16 Apr. 2013
The documentation of min explains this exhaustively already. Type this in Matlab's command window:
help min
doc min
and read it.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (3)

Cedric
Cedric am 15 Apr. 2013
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 Kommentare
Sreeda M A
Sreeda M A am 13 Jul. 2016
can you please explain what values should I give for M ??
Andrei Bobrov
Andrei Bobrov am 13 Jul. 2016
Bearbeitet: Andrei Bobrov am 13 Jul. 2016
Hi Sreeda M A! Example:
M = randi(400,280,307,191);

Melden Sie sich an, um zu kommentieren.


Sean de Wolski
Sean de Wolski am 15 Apr. 2013
Or:
min(min(min(M)))
  2 Kommentare
Ties Hendrickx
Ties Hendrickx am 29 Apr. 2019
Nope, this will return the minimum value and not the index of the minimum value
Cedric
Cedric am 30 Apr. 2019
Just use [~,linIdx] = min(M(:)) and then convert to subscripts using IND2SUB.

Melden Sie sich an, um zu kommentieren.


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

Kategorien

Mehr zu Convert Image Type finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by