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

Home » Public Forums » archive » Instances of structure array with varying no. of elements
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: Instances of structure array with varying no. of elements [message #87366 is a reply to message #87364] Tue, 28 January 2014 08:10 Go to previous messageGo to previous message
Matthew Argall is currently offline  Matthew Argall
Messages: 286
Registered: October 2011
Senior Member
> I tried doing the following for it :
>
> results[0].domain = results[0].domain[0:4]

Structures tags have fixed sizes and types. Since results[0].domain is part of a structure and starts as a 10-element array, it will always be a 10.

The best way to do this is to put your "domain" structures into a list. Lists are dynamic and can change sizes/types. They have a weird way of indexing, though. The following example shows you how to put your structure into a list, then change element 0 of the list to have only 5 instances of "domain".

IDL> temp_results = REPLICATE({domain:REPLICATE({frame :fltarr(1), particles : fltarr(5,6000)}, 10)} , 500)
IDL> results = list(temporary(temp_results), /extract)
IDL> iKeep = [0,1,2,3,4]
IDL> results[0] = results[0,iKeep]
IDL> help, results[0]
<Expression> STRUCT = -> <Anonymous> Array[5]

This is a bit slow, so if you can put your domains directly into the list instead of extracting them, you will be better off.
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Previous Topic: Deleting specific instances of the structure
Next Topic: skip the corrupted hdf file and continue the for lood for uncorrupted hdfs

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

Current Time: Sun Oct 12 02:38:45 PDT 2025

Total time taken to generate the page: 1.67605 seconds