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

Home » Public Forums » archive » Re: more for-loops vs. arrays
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: more for-loops vs. arrays [message #19341 is a reply to message #19337] Wed, 08 March 2000 00:00 Go to previous message
Ben Tupper is currently offline  Ben Tupper
Messages: 186
Registered: August 1999
Senior Member
reardonb@my-deja.com wrote:

> I also have a For-loop vs. array question.
> I want to fill an array with a random sequence of
> 1's and 0's. This works:
>
> array1 = intarr(5,4)
> for I=0,4-1 do begin
> for II=0,5-1 do begin
> array1[II,I] = round(randomu(s))
> endfor
> endfor
>
> but can I do it without for loops?
>

Hello,

I think so... try the following

Arr = RandomU(Seed, 5,4)

Arr = Arr * (Arr GT 0.5)


You could actually shorten this to ...

Arr = RandomU(Seed,5,4) GT 0.5

Be sure to check of the earlier discussion about the random number
generation in IDL , I think it starts with Fun with Random Numbers.

Ben

--
Ben Tupper

Bigelow Laboratory for Ocean Science
tupper@seadas.bigelow.org

pemaquidriver@tidewater.net
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Previous Topic: interpolation around a contour
Next Topic: Re: How do you get rid of for-loops with arrays

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

Current Time: Sun Oct 12 00:32:36 PDT 2025

Total time taken to generate the page: 0.56315 seconds