MATLAB: Matrix

matrixzeros

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

Best Answer

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