Re: Setting Negatives to Zero

• To: mathgroup at smc.vnet.net
• Subject: [mg82794] Re: [mg82736] Setting Negatives to Zero
• From: János <janos.lobb at yale.edu>
• Date: Wed, 31 Oct 2007 06:10:39 -0500 (EST)
• References: <200710300826.DAA13428@smc.vnet.net>

```On Oct 30, 2007, at 4:26 AM, Kevin J. McCann wrote:

> I have a very large data set (64000 x 583) in which negative values
> indicate "no data", unfortunately these negatives are not all the
> same.
> I would like to efficiently set all these negatives to zero. I know =

> that
> I will likely be embarrassed when I see how to do it, but I can't seem
> to remember or figure it out. I should emphasize that because of the
> size of the data set, this needs to be done efficiently. Another
> programming language does it as follows:
>
> 		x(x < 0) = 0;
>
> Thanks,
>
> Kevin
> --
>
> Kevin J. McCann
> Research Associate Professor
> JCET/Physics
> Physics Building
> University of Maryland, Baltimore County
> 1000 Hilltop Circle
> Baltimore, MD 21250

if your data set is called lst, then my newbie approach would be:

In[7]:=
Map[If[#1 < 0, 0, #1] & ,
lst, {2}]

J=E1nos

-------------------------------------------------
clear perl code is better than unclear awk code; but NOTHING comes
close to unclear perl code
http://www.faqs.org/faqs/computer-lang/awk/faq/

```

• Prev by Date: Re: Easy Mapping problem that has me stumped!
• Next by Date: Re: MultivariateDistribution mathematica 6
• Previous by thread: Re: Setting Negatives to Zero
• Next by thread: Re: Setting Negatives to Zero