Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #13988 > unrolled thread
| Started by | dougwangsaif@gmail.com |
|---|---|
| First post | 2013-04-01 04:57 +0000 |
| Last post | 2013-04-03 07:22 +0000 |
| Articles | 4 — 3 participants |
Back to article view | Back to comp.soft-sys.math.mathematica
IntegerPart dougwangsaif@gmail.com - 2013-04-01 04:57 +0000
Re: IntegerPart debguy <johnandsara2@cox.net> - 2013-04-02 07:25 +0000
Re: IntegerPart Peter Pein <petsie@dordos.net> - 2013-04-02 07:25 +0000
Re: IntegerPart debguy <johnandsara2@cox.net> - 2013-04-03 07:22 +0000
| From | dougwangsaif@gmail.com |
|---|---|
| Date | 2013-04-01 04:57 +0000 |
| Subject | IntegerPart |
| Message-ID | <kjb430$8jc$1@smc.vnet.net> |
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}]
[toc] | [next] | [standalone]
| From | debguy <johnandsara2@cox.net> |
|---|---|
| Date | 2013-04-02 07:25 +0000 |
| Message-ID | <kje159$gvi$1@smc.vnet.net> |
| In reply to | #13988 |
I see it doing what you asked. I see a square wave style graph. What is it you want as a result? A square wave of between 0 and 1 using FractionalPart ?? I do see your using IntegerPart on x. That is likely unintended. Plot Evaluates your fun at every x between 1 and nSize to get the value (saves it in a List) and always steps by integer increment 1. You likely wanted to apply IntegerPart to your data not give it to Part as the index into your data. hope that helped
[toc] | [prev] | [next] | [standalone]
| From | Peter Pein <petsie@dordos.net> |
|---|---|
| Date | 2013-04-02 07:25 +0000 |
| Message-ID | <kje15v$gvv$1@smc.vnet.net> |
| In reply to | #13988 |
Am 01.04.2013 06:57, schrieb dougwangsaif@gmail.com:
> 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}]
>
Hi,
the Plot-algorithm simply selects too few supporting points. Adding
the rule PlotPoints -> nSize + 3 to the call to Plot[] will show the
complete graph.
Peter
[toc] | [prev] | [next] | [standalone]
| From | debguy <johnandsara2@cox.net> |
|---|---|
| Date | 2013-04-03 07:22 +0000 |
| Message-ID | <kjglb7$p42$1@smc.vnet.net> |
| In reply to | #13988 |
I see it doing what you asked. I see a square wave style graph. What is it you want as a result? A square wave of between 0 and 1 using FractionalPart ?? I do see your using IntegerPart on x. That is likely unintended. Plot Evaluates your fun at every x between 1 and nSize to get the value (saves it in a List) and always steps by integer increment 1. You likely wanted to apply IntegerPart to your data not give it to Part as the index into your data. hope that helped
[toc] | [prev] | [standalone]
Back to top | Article view | comp.soft-sys.math.mathematica
csiph-web