How can I find the elements of a matrix that are lower than a given number and the minimum of those elements?
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Réponse acceptée
Plus de réponses (1)
Arthur Nascimento
le 28 Août 2018
Modifié(e) : Arthur Nascimento
le 28 Août 2018
To get the indexes of the elements lower than a number you can do:
A = hilb(70);
A<0.01
If you want the value of said elements you can do
A(A<.01)
To find the index of the minimum element you can use
A(A==min(A))
Or the element
min(A)
1 commentaire
Stephan
le 28 Août 2018
Modifié(e) : Stephan
le 28 Août 2018
Note that if A is a matrix, then min(A) is a row vector containing the minimum value of each column.
So
min(A)
will not give the smallest one element from A but a 1x70 vector.
Also note that:
A(A==min(A))
does not give back indices, but a transposed version of the vector made by min(A) with dimensions 70x1.
Voir également
Catégories
En savoir plus sur Hilbert and Walsh-Hadamard Transforms 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!