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

Home » Public Forums » archive » Re: Create new arrays from series of subsequent integers in an existing array
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: Create new arrays from series of subsequent integers in an existing array [message #48813 is a reply to message #48812] Tue, 23 May 2006 15:26 Go to previous messageGo to previous message
Paul Van Delst[1] is currently offline  Paul Van Delst[1]
Messages: 1157
Registered: April 2002
Senior Member
Jonathan Wolfe wrote:
> Thank you both for your help! In regards to JD's saving the output
> arrays with pointers... I have never used pointers and believe this is
> a case in which they are necessary.
>
> After writing a long, drawn out explanation of where I was stuck with
> pointers I ended up figuring them out. Just in case anyone new to
> pointers wants to know how to get variables from an example such as the
> above threads, use something like this:
>
> x= ptrarr(3)
>
> for i = 1L, n_elements(h) - 1L do begin
> t=ri[ri[i]:ri[i+1]-1]
> x[i] = PTR_NEW( t,/allocate_heap )
> endfor
>
> print,*x(2)
>
> and you will have your varying size arrays of a larger array segmented
> into different subscripts of x.
>
> I'm sure there may be a better way to do this, but it makes sense to me.

Not a big change, but you can also do:

n=n_elements(h)
x=ptrarr(n,/ALLOCATE_HEAP)
for i = 0L, n-1L do begin
t=ri[ri[i]:ri[i+1]-1]
*x[i] = t
endfor

BTW, do you really want
for i = 1L, n_elements(h) - 1L
or
for i = 0L, n_elements(h) - 1L

??

You never use x[0] in your orig code.

paulv

--
Paul van Delst Ride lots.
CIMSS @ NOAA/NCEP/EMC Eddy Merckx
Ph: (301)763-8000 x7748
Fax:(301)763-8545
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: SAVE files with /ROUTINES for Previous Versions
Next Topic: PLOTHIST and tick marks

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

Current Time: Sat Oct 11 05:43:52 PDT 2025

Total time taken to generate the page: 1.03792 seconds