Hi, I have a very large matrix. I want to know how many positive elements I have in the matrix, and how many negative elements (non-zero).
Thanks

 採用された回答

Oleg Komarov
Oleg Komarov 2012 年 5 月 28 日

1 投票

idx = A < 0;
nnz( idx) % negative
nnz(~idx) % positive (including 0)

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File Exchange で Numeric Types についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by