-1

I would like to do exactly what is explained in the answer by Jim Lewis to the post below (see link) in the case that each file contains a different number of samples. Jim states that this can be done using PTR_NEW. Any ideas how to use PTR_NEW in the loop showed in the answer?

Thanks, Catia

How to declare variables in for loop? (IDL)

Community
  • 1
  • 1

1 Answers1

0

I think they mean something like:

a = ptrarr(n)
b = ptrarr(n)
c = ptrarr(n)
d = ptrarr(n)

for i = 0L, n - 1L do begin
  readcol, string(i, F='(I02)') + '.dat', F='D,D', x, y
  a[i] = ptr_new(x)
  b[i] = ptr_new(y)
  c[i] = ptr_new(x/x[0])
  d[i] = ptr_new(y/y[0])
endfor

Access like this:

for i = 0L, n - 1L do begin
  help, *a[i]
endfor

In this example, the size and type of x and y can vary each iteration.

mgalloy
  • 2,356
  • 1
  • 12
  • 10