Path: news.mathworks.com!not-for-mail
From: Loren Shure <loren@mathworks.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: repace NaN with zero
Date: Tue, 16 Jun 2009 07:15:02 -0400
Organization: The MathWorks
Lines: 29
Message-ID: <MPG.24a148c2657e88319899df@news.mathworks.com>
References: <h171ga$inm$1@fred.mathworks.com> <h1731i$pue$1@fred.mathworks.com>
NNTP-Posting-Host: shurel.dhcp.mathworks.com
Mime-Version: 1.0
Content-Type: text/plain; charset="iso-8859-15"
Content-Transfer-Encoding: 7bit
X-Trace: fred.mathworks.com 1245150902 21648 172.31.57.206 (16 Jun 2009 11:15:02 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Tue, 16 Jun 2009 11:15:02 +0000 (UTC)
User-Agent: MicroPlanet-Gravity/2.70.2067
Xref: news.mathworks.com comp.soft-sys.matlab:547855


In article <h1731i$pue$1@fred.mathworks.com>, dlISCool@gmail.com says...
> OK I got it
> k = find(isnan(A))';
> A(k) = 0;
> 
> Diego
> 
> 
> "Diego Lass" <dlISCool@gmail.com> wrote in message <h171ga$inm$1@fred.mathworks.com>...
> > Hi
> > I want to replace NaN in the current matrix with 0, what is the fastest way? 
> >  
> > A = [ 1 2 NaN; NaN 2 3; NaN NaN 100 ]
> > 
> > A =
> > 
> >      1     2   NaN
> >    NaN     2     3
> >    NaN   NaN   100
> > 
> > Thanks
> > Diego
> 

No need for the overhead with find.  Follow John D's advice.

-- 
Loren
http://blogs.mathworks.com/loren