Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #14037

Re: what is wrong with this code?

From Bob Hanlon <hanlonr357@gmail.com>
Newsgroups comp.soft-sys.math.mathematica
Subject Re: what is wrong with this code?
Date 2013-04-03 08:07 +0000
Message-ID <kjgo0b$pu4$1@smc.vnet.net> (permalink)
References <20130402072448.3AA276A87@smc.vnet.net>
Organization Time-Warner Telecom

Show all headers | View raw


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@gmail.com> wrote:

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

Back to comp.soft-sys.math.mathematica | Previous | Next | Find similar | Unroll thread


Thread

Re: what is wrong with this code? Bob Hanlon <hanlonr357@gmail.com> - 2013-04-03 08:07 +0000

csiph-web