MathGroup Archive 2013

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

Search the Archive

Re: what is wrong with this code?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg130326] Re: what is wrong with this code?
  • From: Bob Hanlon <hanlonr357 at gmail.com>
  • Date: Wed, 3 Apr 2013 04:08:42 -0400 (EDT)
  • Delivered-to: l-mathgroup@mail-archive0.wolfram.com
  • Delivered-to: l-mathgroup@wolfram.com
  • Delivered-to: mathgroup-newout@smc.vnet.net
  • Delivered-to: mathgroup-newsend@smc.vnet.net
  • References: <20130402072448.3AA276A87@smc.vnet.net>

Same problem that you posted earlier with same resolutions.


However, I woud recommend that you use Piecewise rather than If when
defining a function.


f[x_] := Piecewise[{{0.4, EvenQ[IntegerPart[x]]}}, 0.8]


Plot[f[x], {x, 1, 101}, PlotPoints -> 125]



Bob Hanlon




On Tue, Apr 2, 2013 at 3:24 AM, <dougwangsaif at gmail.com> wrote:

> f[x_] := If[EvenQ[IntegerPart[x]], 0.4, 0.8];
> Plot[f[x], {x, 1, 101}]
>
>



  • Prev by Date: Re: what is wrong with this code?
  • Next by Date: Re: Splice fails (Mathematica 9; Windows)
  • Previous by thread: Re: what is wrong with this code?
  • Next by thread: Re: what is wrong with this code?