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

MathGroup Archive 2009

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

Search the Archive

Re: Replacing Values Close to One

  • To: mathgroup at smc.vnet.net
  • Subject: [mg105310] Re: Replacing Values Close to One
  • From: Joseph Gwinn <joegwinn at comcast.net>
  • Date: Fri, 27 Nov 2009 06:29:37 -0500 (EST)
  • References: <helo66$o4f$1@smc.vnet.net>

In article <helo66$o4f$1 at smc.vnet.net>,
 Alexei Boulbitch <Alexei.Boulbitch at iee.lu> wrote:

> Hello, Georgy, 
> 
> like this?
> 
> f[x_, eps_] := If[Abs[x - 1] < eps, 1, x];
> 
> f[1.03, 0.1]
> f[1.2, 0.1]
> 
> 1
> 
> 1.2
> 
> ??
> Alexei.
> 
> 
> Hello everyone,
> 
> Is there a replacement rule that I can apply to
> 
> 	{-8, .7, 0, 1.003}  /.  [what goes here?] -> 1
> 
> to replace values that are close to 1, like 1.003, by 1?

I don't know that a rule can work, as pattern-matching isn't logic.  Why 
not this:

tolerance=0.004;

Map[If[Abs[# - 1] < tolerance, 1, #]&,{-8, .7, 0, 1.003}]



Joe Gwinn


  • Prev by Date: RevolutionPlot3D: Specifying the axis of rotation
  • Next by Date: Re: Replacing Values Close to One
  • Previous by thread: Re: Replacing Values Close to One
  • Next by thread: Re: Replacing Values Close to One