Re: problem with plot
- To: mathgroup at smc.vnet.net
- Subject: [mg33350] Re: problem with plot
- From: "Allan Hayes" <hay at haystack.demon.co.uk>
- Date: Sun, 17 Mar 2002 05:32:59 -0500 (EST)
- References: <a6updc$hsm$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
"puma" <puma at puma.com> wrote in message news:a6updc$hsm$1 at smc.vnet.net... > Please try this: > << > f[x_]:=0 /; x < 0 || x >= 1; > f[x_]:=1 /; x >= 0 && x < 1/2; > f[x_]:=-1 /; x >= 1/2 && x < 1; > Plot[f[16 x],{x,0,1}]; > Plot[f[16 x],{x,-1,1}]; > > Clear[f]; > >> > why the curve disappear in the 2nd plot? > only x-interval is changed! > ????? Plot takes 25 nearly equally spaced sample points to start with; all of these give the value 0 in the second plot, so nothig further is done. We can avoid this by suitably altering the numbeer of initial sample points using the option PlotPoints (we can also suppress the axes and use a fram instead so that the x-axis is not confused with the curve plotted): f[x_] := 0 /; x < 0 || x >= 1; f[x_] := 1 /; x >= 0 && x < 1/2; f[x_] := -1 /; x >= 1/2 && x < 1; Plot[f[16*x], {x, 0, 1}, Frame -> True, Axes -> False]; Plot[f[16*x], {x, -1, 1}, Frame -> True, Axes -> False]; Plot[f[16*x], {x, -1, 1}, Frame -> True, Axes -> False, PlotPoints -> 26] Table[f[16*x], {x, -1, 1, 2/24}] {0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0} -- Allan --------------------- Allan Hayes Mathematica Training and Consulting Leicester UK www.haystack.demon.co.uk hay at haystack.demon.co.uk Voice: +44 (0)116 271 4198 Fax: +44 (0)870 164 0565 > > > > > > > > >