variables - define array name within a loop -
I am going about it wrongly, but I try to define and fill the array within a loop I am here.
xx = tall for i = 0,39 (findgen (n + 1l) * sx + line1x [i]) sz = size (xx) arrayname = 'line' + strtrim (i , 2)) Arrayname = findgen (3, sz [1]) array name [0, *] = xx arrayname [1, *] = yy arrayname [2, *] = virtual end
It will not work clearly, but is there any way to create a new array on every wavelength and use the string set by 'line' + stratim (i, 2) to fill it? In this case my name will be 40 arrays ... ... 39 The hard part here is that SG [1] varies, so I can not simply define a large array by holding everything.
idl 8.0 or later you can use the HASH
datatype for this Are there.
Your code will look like this: > for ii = 0,39 array_dict = hash () xx = tall (findgen (n + 1l) * sx + line1x [ii ]) Sz = size (xx) arrayname = 'line' + string (1, FORMAT = '(I02)' array = findgen (3, sz [1]) array [0, *] = xx array [1, *] = Yy array [2, *] = vertline array_dict [arrayname] = endfor for the array
You can now use your arrays by name:
< Code> line = array_dict ['line01']
Comments
Post a Comment