MathGroup Archive 2007

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

Search the Archive

Re: Setting Negatives to Zero

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

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
>  
>
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:

http://library.wolfram.com/infocenter/Conferences/7005/

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