How many positive entries in array
66 ビュー (過去 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!