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

Home » Public Forums » archive » Re: how to do a loop in idl using multi-commmand?
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: how to do a loop in idl using multi-commmand? [message #43516] Sun, 17 April 2005 22:37 Go to previous message
Dick Jackson is currently offline  Dick Jackson
Messages: 347
Registered: August 1998
Senior Member
Hi,

"lixiaoyao" <lixiaoyao5880@yahoo.com> wrote in message
news:1113584939.738412.136930@o13g2000cwo.googlegroups.com.. .
> I can run this in my idl,who know how to solve it?
> nH2=findgen(10001)*10.0+0.1
> ratio=make_array(10001)
> for i=0,10000 do
> x=2*nH2[i]
> y=x*nH2[i]
> ratio[i]=x/y
> openw,1,'file'
> printf,1,ratio
> close,1
> it seems to show you can not do multicommand in do loop.
> thanks

The suggestions that others have given are all great, but you may want to
know that you can do the work of this loop using IDL's powerful (and much
faster) array operations as follows:

nH2=findgen(10001)*10.0+0.1

x=2*nH2
y=x*nH2
ratio=x/y

or, if you don't need to make x and y for any other reason:

ratio = (2*nH2) / (2*nH2*nH2)

or then, by factoring:

ratio = 1 / nH2

A useful section in IDL Online Help that covers some features that are
different from many other languages is "Writing Efficient IDL Programs" (in
Programming in IDL:Basics of IDL Programming).

Cheers,
--
-Dick

Dick Jackson / dick@d-jackson.com
D-Jackson Software Consulting / http://www.d-jackson.com
Calgary, Alberta, Canada / +1-403-242-7398 / Fax: 241-7392
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Nice ways to compile
Next Topic: .compile vs .run

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

Current Time: Sat Nov 29 13:14:20 PST 2025

Total time taken to generate the page: 1.84256 seconds