Extract one element from row vectors?
5 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Mary Jon
le 27 Nov 2013
Commenté : Azzi Abdelmalek
le 27 Nov 2013
I have row vectors how can I extract one element from this vector;
A=[1 2 3 4 5]; how extract max value (5)from A MATRIX
to be A=[1 2 3 4]; only
0 commentaires
Réponse acceptée
Plus de réponses (1)
Wayne King
le 27 Nov 2013
Modifié(e) : Wayne King
le 27 Nov 2013
In addition to Azzi's suggestion you can use
A(A~=max(A))
but keep in mind that both will remove multiple values if the max() occurs more than once.
For example:
A = [1 2 3 4 5 5];
If the max occurs more than once, you have to use a different technique to remove which entry you want. For example, say you want to just remove the first time the max occurs
maxval = max(A);
A(find(A==max(A),1,'first'))= [];
Voir également
Catégories
En savoir plus sur Matrices and Arrays dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!