Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2009

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

Search the Archive

Re: Re: Replacing Values Close to One

  • To: mathgroup at smc.vnet.net
  • Subject: [mg105298] Re: [mg105292] Re: Replacing Values Close to One
  • From: Yuri Kandrashkin <spinalgebra at gmail.com>
  • Date: Fri, 27 Nov 2009 06:27:15 -0500 (EST)
  • References: <hekug7$921$1@smc.vnet.net> <200911261114.GAA24561@smc.vnet.net>

Hi,
Here is another version with Chop
{num, eps} = {1, 0.1}
Chop[{-8, .7, 0, 1.003} - num, eps] + num


2009/11/26 M.Roellig <markus.roellig at googlemail.com>

> On 26 Nov., 05:00, Gregory Lypny <gregory.ly... at videotron.ca> wrote:
> > 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?
> >
> > Regards,
> >
> >         Gregory
>
> Hi,
>
> you can use Chop which sets numbers close to zero to zero:
>
> {-8, .7, 0, 1.003} /. x_ :> (Chop[x - 1, 0.01] + 1)
>
>
> here I gave 0.01 as tolerance. Change it to your needs.
>
> Cheers,
>
> Markus
>
>
-- 
Sincerely,
Yuri Kandrashkin



  • Prev by Date: BarChart3D Axes Label Problem
  • Next by Date: NeuralFit running out of memory
  • Previous by thread: Re: Replacing Values Close to One
  • Next by thread: Re: Re: Re: Replacing Values Close to One