Path: news.mathworks.com!not-for-mail
From: "John D'Errico" <woodchips@rochester.rr.com>
Newsgroups: comp.soft-sys.matlab
Subject: repace NaN with zero
Date: Tue, 16 Jun 2009 03:14:02 +0000 (UTC)
Organization: John D'Errico (1-3LEW5R)
Lines: 16
Message-ID: <h172lq$3d2$1@fred.mathworks.com>
References: <h171ga$inm$1@fred.mathworks.com>
Reply-To: "John D'Errico" <woodchips@rochester.rr.com>
NNTP-Posting-Host: webapp-02-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1245122042 3490 172.30.248.37 (16 Jun 2009 03:14:02 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Tue, 16 Jun 2009 03:14:02 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 869215
Xref: news.mathworks.com comp.soft-sys.matlab:547761


"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

A(isnan(A)) = 0;