Mathematica 9 is now available
Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2007

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

Search the Archive

Re: Setting Negatives to Zero

  • To: mathgroup at smc.vnet.net
  • Subject: [mg82798] Re: [mg82736] Setting Negatives to Zero
  • From: DrMajorBob <drmajorbob at bigfoot.com>
  • Date: Wed, 31 Oct 2007 06:12:42 -0500 (EST)
  • References: <7189487.1193744482274.JavaMail.root@m35>
  • Reply-to: drmajorbob at bigfoot.com

data = data /. x_?Negative -> 0

or something like

Attributes[negToZero]={Listable}
negToZero[x_?NumericQ] = Sign[x] x
data = negToZero@data

Bobby

On Tue, 30 Oct 2007 03:26:37 -0500, Kevin J. McCann  
<Kevin.McCann at umbc.edu> 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



-- 

DrMajorBob at bigfoot.com


  • Prev by Date: ANN: ColorbarPlot
  • Next by Date: Re: Vectors,Norms and assumptions
  • Previous by thread: Re: Setting Negatives to Zero
  • Next by thread: Re: Setting Negatives to Zero