How many positive entries in array

66 次查看(过去 30 天)
I have a 1450x1 array. I want to count how many positive entries in array?

采纳的回答

Wayne King
Wayne King 2012-4-1
x = randn(1450,1);
indices = find(x>0);
length(indices)
or
count = length(nonzeros(x(x>0)));

更多回答(1 个)

hidayet beyhan
hidayet beyhan 2020-3-28
编辑:hidayet beyhan 2020-3-28
Or you can use for an array:
x = randn(1450,1);
sum(x>0)

类别

Help CenterFile Exchange 中查找有关 Matrices and Arrays 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by