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

Home » Public Forums » archive » Re: compare 2-d array with vector
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: compare 2-d array with vector [message #81548 is a reply to message #81547] Mon, 24 September 2012 04:39 Go to previous messageGo to previous message
Heinz Stege is currently offline  Heinz Stege
Messages: 189
Registered: January 2003
Senior Member
On Mon, 24 Sep 2012 00:32:17 -0700 (PDT), Danxia wrote:

> Hi all, I'm having problem when comparing a 2-d array with a given vector. For example, if giving a 2-d array
> a=[[1,1,1],
> [2,2,2],
> [3,3,3],
> [4,4,4]]
> and a vector b=[1,2],
> how can I get all the subscripts of array a that's equal to any element in vector b, which in this example is [0,1,2,3,4,5]. Please let me know if I failed to make this clear. Looking forward to any reply. Thank you very much!

Hi Danxia,

the use of the value_locate function is very helpful:

subscripts=where(a eq b[value_locate(b,a)>0])

Note that b must be sorted and must have 2 or more elements. ">0" may
be omitted, if a is an array (and you have not enabled the
STRICTARRSUBS compiler option).

Cheers, Heinz
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: copying pointers in structures
Next Topic: interpolation of two different model

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

Current Time: Wed Oct 08 17:24:40 PDT 2025

Total time taken to generate the page: 0.00427 seconds