Re: Issue with long integer arrays [message #86967 is a reply to message #86966] |
Tue, 17 December 2013 12:12   |
Daniel Otis
Messages: 5 Registered: January 2012
|
Junior Member |
|
|
On Tuesday, December 17, 2013 2:42:49 PM UTC-5, Helder wrote:
> On Tuesday, December 17, 2013 8:20:38 PM UTC+1, do...@mail.usf.edu wrote:
>
>> I should know this, but am having trouble with the following:
>
>>
>
>>
>
>>
>
>> I have several long integer(long) arrays that are restored into the workspace.
>
>>
>
>>
>
>>
>
>> I want to define an array so that my long arrays can be used in a loop later in my program.
>
>>
>
>>
>
>>
>
>> array1=long[25248]
>
>>
>
>> array1=long[2905]
>
>>
>
>> array1=long[4651]
>
>>
>
>> array1=long[4988]
>
>>
>
>>
>
>>
>
>> These are masks used to extract different regions of an image.
>
>>
>
>>
>
>>
>
>> How can I put the arrays into one variable that can be called in a loop?
>
>>
>
>>
>
>>
>
>> It should be simple, but I'm stumped. Thanks,
>
>>
>
>>
>
>>
>
>> Dan
>
>
>
> There are more ways of doing this and depend on thing such as if you know the sizes before hand and so on. So I'll offer one and might not just be the best for your case, but I hope it helps.
>
>
>
> pa = ptrarr(4,/allocate_heap)
>
> *pa[0]=long[25248]
>
> *pa[1]=long[2905]
>
> *pa[2]=long[4651]
>
> *pa[3]=long[4988]
>
>
>
> For i=0,3 do begin
>
> ;your work
>
> print, mean(*pa[i])
>
> endfor
>
>
>
> If you know the sizes before hand, one other solution would be to make one array long as the 4 together and then subscript the array.
>
>
>
> Cheers,
>
> Helder
Thanks. Works great. Never used ptrarr.
|
|
|