How many positive entries in array
40 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I have a 1450x1 array. I want to count how many positive entries in array?
0 commentaires
Réponse acceptée
Wayne King
le 1 Avr 2012
x = randn(1450,1);
indices = find(x>0);
length(indices)
or
count = length(nonzeros(x(x>0)));
0 commentaires
Plus de réponses (1)
hidayet beyhan
le 28 Mar 2020
Modifié(e) : hidayet beyhan
le 28 Mar 2020
Or you can use for an array:
x = randn(1450,1);
sum(x>0)
0 commentaires
Voir également
Catégories
En savoir plus sur Creating and Concatenating Matrices 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!