[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: FOR statement
Eli Beckerman wrote:
> I just tried running a FOR loop in the hopes
> of incrementing the variable "i" by steps of 0.25 as follows:
> FOR i=0.0, 100.0, 0.25 DO BEGIN
> And what I end up with is an array that starts
> with the value 0.75 and is incremented by steps of 1.
> I'm following the convention of the FOR statement as
> presented in IDL's online help. What am I doing wrong?!
FOR xi=0.0, 100.0, 0.25 DO BEGIN & i=i+1L & radius(i)=xi & endfor
IDL> print, radius[0:10]
0.00000 0.250000 0.500000 0.750000 1.00000 1.25000
1.75000 2.00000 2.25000 2.50000
using i as the array subscript must be converting it to an integer type and screwing stuff
Using loop indices like this should be discouraged, I reckon.
Paul van Delst A little learning is a dangerous thing;
CIMSS @ NOAA/NCEP Drink deep, or taste not the Pierian spring;
Ph: (301)763-8000 x7274 There shallow draughts intoxicate the brain,
Fax:(301)763-8545 And drinking largely sobers us again.
email@example.com Alexander Pope.