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

Home » Public Forums » archive » Re: Array comparison
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: Array comparison [message #32356 is a reply to message #32352] Tue, 01 October 2002 17:07 Go to previous message
mchinand is currently offline  mchinand
Messages: 66
Registered: September 1996
Member
In article <and6i0$8l4$1@newsreader.wustl.edu>,
Sean Raffuse <sean@me.wustl.edu> wrote:
> Hello,
>
> I would like to compare two arrays of different size. What I want to know
> is if the two arrays share ANY of the same values, regardless of index.
>
> e.g.
>
> Array1 = [1,2,3,4,5]
> Array2 = [5,6,7]
>
> Comparing these two arrays should return true because they both have the
> value 5.
>
> I know I could do this in a loop, but I need the speed and I'm sure IDL can
> do this in one line. I'm just not sure how.
>
> Thanks,
>
> Sean Raffuse
>
>

How about:

if n_elements(uniq(([a,b])(sort([a,b])))) ne n_elements([a,b]) then print,
'arrays have matching values'


--Mike


--
Michael Chinander
m-chinander@uchicago.edu
Department of Radiology
University of Chicago
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Looking for more ideas on code ...
Next Topic: Re: ROI application...

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

Current Time: Wed Oct 08 16:57:50 PDT 2025

Total time taken to generate the page: 0.00232 seconds