How many positive entries in array

 Risposta accettata

x = randn(1450,1);
indices = find(x>0);
length(indices)
or
count = length(nonzeros(x(x>0)));

Più risposte (1)

hidayet beyhan
hidayet beyhan il 28 Mar 2020
Modificato: hidayet beyhan il 28 Mar 2020

1 voto

Or you can use for an array:
x = randn(1450,1);
sum(x>0)

Categorie

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by