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

 Respuesta aceptada

James Tursa
James Tursa el 15 de Abr. de 2013
Editada: James Tursa el 15 de Abr. de 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 comentarios

Rawan hamdi
Rawan hamdi el 16 de Abr. de 2013
thanks but what are the m & n ?
The documentation of min explains this exhaustively already. Type this in Matlab's command window:
help min
doc min
and read it.

Iniciar sesión para comentar.

Más respuestas (3)

Cedric
Cedric el 15 de Abr. de 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 comentarios

Rawan hamdi
Rawan hamdi el 16 de Abr. de 2013
Editada: Rawan hamdi el 16 de Abr. de 2013
i don't know what argmin means actually,
i have an equation like this :
x = arg min |g-u|.^2 g and u are 2 multibanded images
and im trying to implement it in matlab
Jan
Jan el 16 de Abr. de 2013
Why do you want to implement something, when you do not know its mathematical meaning?
Sreeda M A
Sreeda M A el 13 de Jul. de 2016
can you please explain what values should I give for M ??
Andrei Bobrov
Andrei Bobrov el 13 de Jul. de 2016
Editada: Andrei Bobrov el 13 de Jul. de 2016
Hi Sreeda M A! Example:
M = randi(400,280,307,191);

Iniciar sesión para comentar.

Sean de Wolski
Sean de Wolski el 15 de Abr. de 2013
Or:
min(min(min(M)))

2 comentarios

Ties Hendrickx
Ties Hendrickx el 29 de Abr. de 2019
Nope, this will return the minimum value and not the index of the minimum value
Cedric
Cedric el 30 de Abr. de 2019
Just use [~,linIdx] = min(M(:)) and then convert to subscripts using IND2SUB.

Iniciar sesión para comentar.

Steven Lord
Steven Lord el 30 de Abr. de 2019

0 votos

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

Preguntada:

el 15 de Abr. de 2013

Respondida:

el 30 de Abr. de 2019

Community Treasure Hunt

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

Start Hunting!

Translated by