comparing column vectors finding maxima element wise
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
David Toebaert
le 4 Août 2021
Réponse apportée : David Toebaert
le 4 Août 2021
From two column vectors, I want to create a new one containing the row-per-row maximum of the two vectors compared.
So e.g. from a=[1 2 3 4 5]' and b=[0 2 2 5 6]' I want to create c=[1 2 3 5 6]'
Is there a single command for this?
I cannot use "max([a b])" because that will give [5 6] :(
David
0 commentaires
Réponse acceptée
Simon Chan
le 4 Août 2021
No a single command.....not sure you accept or not.
b.*(b>a)+a.*(a>=b)
0 commentaires
Plus de réponses (1)
Voir également
Catégories
En savoir plus sur NaNs 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!