Re: indexing structure of structures [message #49370] |
Tue, 18 July 2006 08:28 |
Phony Account
Messages: 14 Registered: May 2005
|
Junior Member |
|
|
Ben Tupper wrote:
> phaccount@nycap.rr.com wrote:
>> Hello group,
>>
>> I am analyzing a bunch of data from an experimental series. The
>> analysis from each experiment (numbers a,b,c,... etc) is stored in a
>> structure. For reasons that have little to do with foresight and
>> expedience, I decided to store all the individual structures in one
>> large structure (This allows me to add some more fluff).
>>
>> My problem is how to extract the parameter 'a' to plot it. I was
>> hoping that an array indexing method such as
>>
>> outer_struct.([1,4,8,12]).a
>>
>> would work, but it does not. So I am re-packaging the outer structure
>> as a vector of inner_structures.
>>
>> Am I missing something in the IDL syntax that would allow me to keep
>> the structure of structures, and vectorially index the substructures?
>>
>
> Hello,
>
> I think you really do want a vector of stuctures - assuming that each of
> the structures have the same form. If that is what you want then the
> notation is very simple. Try the following...
>
> vec = REPLICATE($
> {NAME: STRING(randomn(n, 1)*100, format = '(I3.3)'), $
> DATA: INDGEN(4)}, 5)
> help, vec
> subvec = vec[2:4]
> help, subvec
> subname = vec[2:4].name
> help, subname
> subdata = vec[2:4].data
> help, subdata
> subsubdata = vec[2:4].data[3]
> help, subsubdata
>
> Cheers,
> Ben
Yep, that is the way I finally went.
Thanks Ben,
Mirko
|
|
|
Re: indexing structure of structures [message #49375 is a reply to message #49370] |
Tue, 18 July 2006 05:46  |
btt
Messages: 345 Registered: December 2000
|
Senior Member |
|
|
phaccount@nycap.rr.com wrote:
> Hello group,
>
> I am analyzing a bunch of data from an experimental series. The
> analysis from each experiment (numbers a,b,c,... etc) is stored in a
> structure. For reasons that have little to do with foresight and
> expedience, I decided to store all the individual structures in one
> large structure (This allows me to add some more fluff).
>
> My problem is how to extract the parameter 'a' to plot it. I was
> hoping that an array indexing method such as
>
> outer_struct.([1,4,8,12]).a
>
> would work, but it does not. So I am re-packaging the outer structure
> as a vector of inner_structures.
>
> Am I missing something in the IDL syntax that would allow me to keep
> the structure of structures, and vectorially index the substructures?
>
Hello,
I think you really do want a vector of stuctures - assuming that each of
the structures have the same form. If that is what you want then the
notation is very simple. Try the following...
vec = REPLICATE($
{NAME: STRING(randomn(n, 1)*100, format = '(I3.3)'), $
DATA: INDGEN(4)}, 5)
help, vec
subvec = vec[2:4]
help, subvec
subname = vec[2:4].name
help, subname
subdata = vec[2:4].data
help, subdata
subsubdata = vec[2:4].data[3]
help, subsubdata
Cheers,
Ben
|
|
|