matrix

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 中查找有关 Sparse Matrices 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by