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 #24754 is a reply to message #24753] Thu, 12 April 2001 09:12 Go to previous messageGo to previous message
Liam E. Gumley is currently offline  Liam E. Gumley
Messages: 378
Registered: January 2000
Senior Member
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:
>
> 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?!

You are using I as both an array index and a loop variable. This is not
a good idea.

Try this instead:

nx = 1000 ; number of values required
dx = 0.25 ; step size
x1 = 0.0 ; start value

radius = lindgen(nx) * dx + x1

print, radius[0:5]

Bottom line: Don't use loops to create mesh vectors or arrays.

Cheers,
Liam.
http://cimss.ssec.wisc.edu/~gumley/
[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 00:56:12 PDT 2025

Total time taken to generate the page: 0.00193 seconds