Re: IntegerPart
- To: mathgroup at smc.vnet.net
- Subject: [mg130315] Re: IntegerPart
- From: Sseziwa Mukasa <mukasa at gmail.com>
- Date: Tue, 2 Apr 2013 03:29:09 -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: <20130401045851.848996A96@smc.vnet.net>
Nothing's wrong with IntegerPart, Plot doesn't necessarily sample the point you expect by default. You can increase the number of points and subdivisions to get what I assume is your expected Plot: Plot[{prefstate[[IntegerPart[x]]]}, {x, 1, nSize}, PlotPoints -> 67, MaxRecursion -> 6, AxesOrigin -> {0, 0}, TicksStyle -> Directive[18], PlotStyle -> {Black}] On Apr 1, 2013, at 12:58 AM, dougwangsaif at gmail.com wrote: > can anyone help with this. There seems to be something wrong with the IntegerPart function. Please help! > > Clear["Global`*"] > nSize = 100; > > prefstate = Table[0, {i, 1, nSize}]; > Do[ > {prefstate[[i]] = If[EvenQ[i], 0.8, 0.4]}, > {i, 1, nSize} > ]; > > Plot[{prefstate[[IntegerPart[x]]]}, {x, 1, nSize + 1}, > AxesOrigin -> {0, 0}, TicksStyle -> Directive[18], > PlotStyle -> {Black}] >