MathGroup Archive 2007

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Setting Negatives to Zero

  • To: mathgroup at
  • Subject: [mg82822] Re: [mg82736] Setting Negatives to Zero
  • From: Carl Woll <carlw at>
  • Date: Wed, 31 Oct 2007 06:25:03 -0500 (EST)
  • References: <>

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;
I think the fastest approach will be to use the function Clip:

Clip[data, {0, Infinity}]

By the way, I discussed some methods for efficiently programming tasks 
like yours in Mathematica in my talk at the 2007 Wolfram Technology 
Conference, which you can find at:

Carl Woll
Wolfram Research

  • Prev by Date: Re: vector representation
  • Next by Date: Re: library.wolfram submissions
  • Previous by thread: Setting Negatives to Zero
  • Next by thread: Re: Setting Negatives to Zero