Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
How to judge a large matrix containing a Nan?

Subject: How to judge a large matrix containing a Nan?

From: zedong

Date: 1 Jan, 2009 07:12:05

Message: 1 of 3

I now have a sparse matrix which is computed by me(coming from a discretization of partial differential equation,I have used mex file ).
for example:A is a 10000 by 10000 sparse matrix.
x=A\b (in which b is a 10000 by 1 matrix).
I have found that there is some Nan in x.I guess maybe A also has some nan.How to judge that A(i,j) is Nan?Thank you all

Subject: How to judge a large matrix containing a Nan?

From: Brian Borchers

Date: 1 Jan, 2009 07:31:00

Message: 2 of 3

On Jan 1, 12:12 am, "zedong " <zdon...@gmail.com>
>How to judge that A(i,j) is Nan?

The isnan() function will do this for you. In particular,

nnz(isnan(A))

will tell you how many NaN's are in the matrix A, while

isnan(A)

will give you a sparse matrix with 1's in the same positions as the
NaN's in A.

Subject: How to judge a large matrix containing a Nan?

From: Rune Allnor

Date: 1 Jan, 2009 10:21:15

Message: 3 of 3

On 1 Jan, 08:12, "zedong " <zdon...@gmail.com> wrote:
> I now have a sparse matrix which is computed by me(coming from a discretization of partial differential equation,I have used mex file ).
> for example:A is a 10000 by 10000 sparse matrix.
> x=A\b (in which b is a 10000 by 1 matrix).
> I have found that there is some Nan in x.I guess maybe A also has some nan.How to judge that A(i,j) is Nan?Thank you all

ISNAN should tell you whether A contains NaNs. If it does, you would
want to have a look at the mex file which generates A to find out
why they occur.

Rune

Tags for this Thread

What are tags?

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