MathGroup Archive 2013

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

Search the Archive

Re: what is wrong with this code?


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?