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

Home » Public Forums » archive » Re: Add a new tag for anonymous structure array
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: Add a new tag for anonymous structure array [message #58861] Thu, 21 February 2008 22:03
geonline714 is currently offline  geonline714
Messages: 7
Registered: April 2007
Junior Member
Wayne,

Thank you so much!!! I was using loop to solve the problem, but your
method is much better!

Sincerely,
Qi
On Feb 21, 5:24 pm, wlandsman <wlands...@gmail.com> wrote:
> On Feb 21, 7:20 pm, geonline...@gmail.com wrote:
>
>> I have an anonymous structure array, say, A.Let us assume the size of
>> the array is 100. Each structure has tags A, B,C. I want to add a new
>> tag, D. How to do that in IDL?
>> I tried:
>> myStruct = create_struct(A, 'D',0), but it failed.
>
>> It seems that the above syntax works only for an individual structure
>> instead of structure array.
>> For example,
>
>> myStruct = create_struct(A[0],'D',0) and it works.
>
>> This is an issue that can be easily solved in matlab. I am not sure
>> whether IDL provides straightforward method to do that.
>
> I wouldn't call this straightforward but the task can be accomplished
> by
>
> myStruct = replicate( create_struct(A[0],'D',0),
> N_elements(A) ) ;Create the new structure
> Struct_Assign, a, myStruct ;Fill with values from the original
> structure
>
> --Wayne
Re: Add a new tag for anonymous structure array [message #58862 is a reply to message #58861] Thu, 21 February 2008 19:24 Go to previous message
wlandsman is currently offline  wlandsman
Messages: 743
Registered: June 2000
Senior Member
On Feb 21, 7:20 pm, geonline...@gmail.com wrote:
> I have an anonymous structure array, say, A.Let us assume the size of
> the array is 100. Each structure has tags A, B,C. I want to add a new
> tag, D. How to do that in IDL?
> I tried:
> myStruct = create_struct(A, 'D',0), but it failed.
>
> It seems that the above syntax works only for an individual structure
> instead of structure array.
> For example,
>
> myStruct = create_struct(A[0],'D',0) and it works.
>
> This is an issue that can be easily solved in matlab. I am not sure
> whether IDL provides straightforward method to do that.

I wouldn't call this straightforward but the task can be accomplished
by

myStruct = replicate( create_struct(A[0],'D',0),
N_elements(A) ) ;Create the new structure
Struct_Assign, a, myStruct ;Fill with values from the original
structure

--Wayne
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Add a new tag for anonymous structure array
Next Topic: Re: Confluent Hypergeometric Function of the First Kind

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

Current Time: Wed Oct 08 16:00:26 PDT 2025

Total time taken to generate the page: 0.00530 seconds