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

 Respuesta aceptada

Oleg Komarov
Oleg Komarov el 28 de Mayo de 2012

1 voto

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

Más respuestas (0)

Categorías

Más información sobre Sparse Matrices en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 28 de Mayo de 2012

Community Treasure Hunt

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

Start Hunting!

Translated by