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

Home » Public Forums » archive » Re: allocating data to different array on each loop step
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: allocating data to different array on each loop step [message #46261 is a reply to message #46260] Sun, 13 November 2005 18:02 Go to previous messageGo to previous message
Richard French is currently offline  Richard French
Messages: 173
Registered: December 2000
Senior Member
On 11/13/05 8:50 PM, in article
1131933033.894813.142800@z14g2000cwz.googlegroups.com, "snfinder@naver.com"
<snfinder@naver.com> wrote:

> Thank you Coyote~ ^^
>
> But If the number of loop step is so large,
> array1 = *arrays[0]
> array2 = *arrays[1]
> ...
> array24 = *arrays[23]
> this is very unefficient.
>
> I want to excute this automatically.
>
> And I can't know the number of loop step before end of all steps.
> um...ok can find out it if I excute loop twice......ok..
>
> Thank you ~
>

Well, you can use the EXECUTE command if you want to define the variables on
the fly:



pro arrays
for n=1L,10 do begin
;create arrays of different sizes
array=findgen(n)#findgen(10*n)
; construct a command to execute, defining the new variable name
cmd=string(n,format='("array",I0,"=array")')
print,cmd
result=execute(cmd)
endfor
help
end


IDL> arrays
array1=array
array2=array
array3=array
array4=array
array5=array
array6=array
array7=array
array8=array
array9=array
array10=array
% At ARRAYS 8 /Users/rfrench/arrays.pro
% $MAIN$
ARRAY FLOAT = Array[10, 100]
ARRAY1 FLOAT = Array[1, 10]
ARRAY10 FLOAT = Array[10, 100]
ARRAY2 FLOAT = Array[2, 20]
ARRAY3 FLOAT = Array[3, 30]
ARRAY4 FLOAT = Array[4, 40]
ARRAY5 FLOAT = Array[5, 50]
ARRAY6 FLOAT = Array[6, 60]
ARRAY7 FLOAT = Array[7, 70]
ARRAY8 FLOAT = Array[8, 80]
ARRAY9 FLOAT = Array[9, 90]
CMD STRING = 'array10=array'
N LONG = 11
RESULT INT = 1


Dick French
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: Access to title object in IDLgrAxis
Next Topic: subscripting arrays with dim > 1

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

Current Time: Fri Oct 10 04:56:46 PDT 2025

Total time taken to generate the page: 0.00493 seconds