How many positive entries in array
44 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
I have a 1450x1 array. I want to count how many positive entries in array?
0 Commenti
Risposta accettata
Wayne King
il 1 Apr 2012
x = randn(1450,1);
indices = find(x>0);
length(indices)
or
count = length(nonzeros(x(x>0)));
0 Commenti
Più risposte (1)
hidayet beyhan
il 28 Mar 2020
Modificato: hidayet beyhan
il 28 Mar 2020
Or you can use for an array:
x = randn(1450,1);
sum(x>0)
0 Commenti
Vedere anche
Categorie
Scopri di più su Creating and Concatenating Matrices in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!