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

 Réponse acceptée

Oleg Komarov
Oleg Komarov le 28 Mai 2012

1 vote

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

Plus de réponses (0)

Catégories

En savoir plus sur Sparse Matrices dans Centre d'aide et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by