Borrar filtros
Borrar filtros

Find minimum in matrice

4 visualizaciones (últimos 30 días)
Miguel Albuquerque
Miguel Albuquerque el 16 de Jul. de 2022
Respondida: patrick1704 el 16 de Jul. de 2022
Hey guys, thanks in advance
I have this matrix, that always has zeros, but also other values. I want to find the minimum of the matrix, besides the zeros, how can I do that?

Respuesta aceptada

patrick1704
patrick1704 el 16 de Jul. de 2022
Hi,
If you only care about the value and not the index, you could do something like this:
min(R1_matrix(R1_matrix ~= 0))
If you care about the index you could do something like:
R1_matrix(R1_matrix == 0) = inf;
min(R1_matrix)

Más respuestas (1)

KSSV
KSSV el 16 de Jul. de 2022
Editada: KSSV el 16 de Jul. de 2022
Let A be your matrix.
A(A==0) = NaN ; % replace 0's with NaNs
[val,idx] = min(A)
Or, use:
val = min(A(A>0))

Categorías

Más información sobre Mathematics en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by