Effacer les filtres
Effacer les filtres

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

27 vues (au cours des 30 derniers jours)
Rawan hamdi
Rawan hamdi le 15 Avr 2013
Hi, i'm having an image of size[280,307,191] and i want to get the argmin of it,Any help?

Réponse acceptée

James Tursa
James Tursa le 15 Avr 2013
Modifié(e) : James Tursa le 15 Avr 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 commentaires
Rawan hamdi
Rawan hamdi le 16 Avr 2013
thanks but what are the m & n ?
Jan
Jan le 16 Avr 2013
The documentation of min explains this exhaustively already. Type this in Matlab's command window:
help min
doc min
and read it.

Connectez-vous pour commenter.

Plus de réponses (3)

Cedric
Cedric le 15 Avr 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 commentaires
Sreeda M A
Sreeda M A le 13 Juil 2016
can you please explain what values should I give for M ??
Andrei Bobrov
Andrei Bobrov le 13 Juil 2016
Modifié(e) : Andrei Bobrov le 13 Juil 2016
Hi Sreeda M A! Example:
M = randi(400,280,307,191);

Connectez-vous pour commenter.


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

Connectez-vous pour commenter.


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

Catégories

En savoir plus sur Convert Image Type dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by