Effacer les filtres
Effacer les filtres

Check if all vector elements have same sign

16 vues (au cours des 30 derniers jours)
Oscar Frick
Oscar Frick le 31 Mai 2018
Commenté : Oscar Frick le 1 Juin 2018
Is there an efficient (and easy) way to check if all elements of a vector have the same sign (not caring about zero values)?
I can think of applying sign(v) and checking if all elements is equal to the first one after having removed all elements where sign(v)==0, but this fells somewhat clumsy. Is there an easier or more efficient way?

Réponse acceptée

Stephen23 le 31 Mai 2018
Modifié(e) : Stephen23 le 31 Mai 2018
true if all non-zero elements of V have the same sign:

Plus de réponses (0)


En savoir plus sur Deep Learning Toolbox 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