Subject: nnz
From: Wendy
Date: 8 Dec, 2010 04:36:05
Message: 1 of 2
Hi all, I have a matrix, such as A = 1 1 1 1 0 1 1 1 1 1 1 0 0 1 0 I want to count the number of non-zeros in each row. Is there a matrix function that I can use instead of looping through the rows. The output that I expect is output = 4 5 2 Thanks, Wendy
From: Walter Roberson
Date: 8 Dec, 2010 04:49:14
Message: 2 of 2
On 07/12/10 10:36 PM, Wendy wrote: > I have a matrix, such as > > A = 1 1 1 1 0 > 1 1 1 1 1 > 1 0 0 1 0 > > > I want to count the number of non-zeros in each row. sum(logical(A),2)
A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.
Anyone can tag a thread. Tags are public and visible to everyone.
Contact us