採用された回答

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)));

その他の回答 (2 件)

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)
Varshitha Gouri
Varshitha Gouri 2026 年 7 月 7 日

0 投票

function count = positiveEntries(arr)
count = sum(arr > 0);
end

カテゴリ

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

タグ

質問済み:

2012 年 4 月 1 日

回答済み:

2026 年 7 月 7 日

Community Treasure Hunt

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

Start Hunting!

Translated by