help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NaN in matrix


From: Søren Hauberg
Subject: Re: NaN in matrix
Date: Thu, 14 May 2009 16:54:39 +0200

tor, 14 05 2009 kl. 08:45 -0500, skrev Xin Dong:
> I wanna calculate the correlation of a matrix but I got a lot of NaN.
> I guess the problem is that some of the elements are NaN. Because the
> matrix is very big, I can't print it out to check. How can I know if
> there are NaNs in the matrix? And if there are, how can I change them
> to 0?

To compute number of NaNs:

  number_of_nans = sum (isnan (matrix (:)))

To replace them with zeros

  matrix (isnan (matrix)) = 0;

should do the trick

Søren





reply via email to

[Prev in Thread] Current Thread [Next in Thread]