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

Home » Public Forums » archive » do loop
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
do loop [message #93046] Fri, 15 April 2016 06:13 Go to next message
Ali Gamal is currently offline  Ali Gamal
Messages: 98
Registered: June 2013
Member
hi, I have
col1 =dep[0, 0: 49]
col11 =dep[0, 50: 99]
col21 =dep[0, 100:149]
col31 =dep[0, 150:199]
col41 =dep[0, 200:249]
col51 =dep[0, 250:299]
col61 =dep[0, 300:349]
col71 =dep[0, 350:399]
col81 =dep[0, 400:449]
col91 =dep[0, 450:499]
;;;;;;;;;;;;;;;;;;;;;;;;;;
I want to make this as do loop how can i do it ?
Re: do loop [message #93047 is a reply to message #93046] Fri, 15 April 2016 07:01 Go to previous messageGo to next message
greg.addr is currently offline  greg.addr
Messages: 160
Registered: May 2007
Senior Member
Don't try to put the indices in the variable name - you'll regret it. Do this instead:

col=reform(dep[0,0:499],50,10)

then you can access your 'col1' with col[*,0], 'col11' with col[*,1] etc.

Otherwise your next question will be "How do I loop through col1, col11...?"

See previous post... https://groups.google.com/forum/?hl=en#!topic/comp.lang.idl- pvwave/XNn-lBi9DGQ

cheers,
greg
Re: do loop [message #93075 is a reply to message #93047] Thu, 21 April 2016 08:48 Go to previous message
tonyhey is currently offline  tonyhey
Messages: 1
Registered: April 2016
Junior Member
If you really need the index names, use (ordered) hash variable:
You can use it as normal variables and also loop thru this


IDL>dep = findgen(1,500)
IDL>col = orderedhash()

IDL>for i=0, 9 do $
IDL> col[string(i,form='(i1.1)')+'1'] = dep[0,(i*50):((i+1)*50)-1]

IDL> foreach values, col, name do print,name
IDL> help,col['31']
IDL> print,col['51']

A.
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Bootstrap analysis in IDL
Next Topic: running script

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

Current Time: Wed Oct 08 15:34:58 PDT 2025

Total time taken to generate the page: 0.00485 seconds