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

Home » Public Forums » archive » Re: basic array-structure understanding question
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: basic array-structure understanding question [message #63813 is a reply to message #63674] Wed, 19 November 2008 08:47 Go to previous message
Jean H. is currently offline  Jean H.
Messages: 472
Registered: July 2006
Senior Member
> thanks Marc! the knot is coming undone..
> it's a pity that IDL does not associate the two arrays. But I guess
> nobody's perfect :) (or is there a way to TELL IDL to associate them?)
> cheers for the explanation. I'll go hunt around for some more of
> David's articles on this topic.
> juls

As Marc pointed it out, the link is very easy to conceptualize...
select the index on array A and select the corresponding data on array B!

A = [0,1,1,0,1] ;a mask
B = [1,2,3,4,5] ;some data

goodIndex = where(A eq 1)
print, B[goodIndex]
==> 2,3,5


Now, be careful when you do a subscription using where. Your code will
miserably fail in case there is no valid subscript!
ex:
A = [0,1,1,0,1] ;a mask
B = [1,2,3,4,5] ;some data

badIndex = where(A eq 3)
print, badIndex
==> -1
print, B[badIndex]
==> ERROR!

so, unless you are 100% sure that there is ALWAYS a valid index, you
should first search for the index, make sure there is at least 1 valid
one, and then do the subscription!

Jean
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Previous Topic: bake a cake
Next Topic: Re: LAPACK routines

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

Current Time: Sat Nov 29 05:28:18 PST 2025

Total time taken to generate the page: 1.36582 seconds