How many positive entries in array

I have a 1450x1 array. I want to count how many positive entries in array?

 採用された回答

Wayne King
Wayne King 2012 年 4 月 1 日

3 投票

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 日

1 投票

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

カテゴリ

ヘルプ センター および File ExchangeCreating and Concatenating Matrices についてさらに検索

タグ

質問済み:

2012 年 4 月 1 日

編集済み:

2020 年 3 月 28 日

Community Treasure Hunt

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

Start Hunting!

Translated by