comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: FOR statement
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: FOR statement [message #24755 is a reply to message #24754] Thu, 12 April 2001 08:57 Go to previous messageGo to previous message
Paul van Delst is currently offline  Paul van Delst
Messages: 364
Registered: March 1997
Senior Member
Eli Beckerman wrote:
>
> Hey,
>
> I just tried running a FOR loop in the hopes
> of incrementing the variable "i" by steps of 0.25 as follows:
>
> radius=fltarr(1000)
> FOR i=0.0, 100.0, 0.25 DO BEGIN
>
> radius(i)=i
>
> ENDFOR
>
> 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?!

Try

i=-1L
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.50000
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
up somehow.

Using loop indices like this should be discouraged, I reckon.

paulv

--
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.
paul.vandelst@noaa.gov Alexander Pope.
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: MAKE_ARRAY question
Next Topic: IDLgrWindow, Map_Patch, and contours

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Sat Oct 11 15:33:31 PDT 2025

Total time taken to generate the page: 0.71867 seconds