How many positive entries in array
62 次查看(过去 30 天)
显示 更早的评论
I have a 1450x1 array. I want to count how many positive entries in array?
0 个评论
采纳的回答
Wayne King
2012-4-1
x = randn(1450,1);
indices = find(x>0);
length(indices)
or
count = length(nonzeros(x(x>0)));
0 个评论
更多回答(1 个)
hidayet beyhan
2020-3-28
编辑:hidayet beyhan
2020-3-28
Or you can use for an array:
x = randn(1450,1);
sum(x>0)
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Matrices and Arrays 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!