help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Comparing vectors


From: Mike B.
Subject: Re: Comparing vectors
Date: Sun, 24 Jan 2010 23:44:27 -0800 (PST)

Hi Jaroslav,

Thanks for replying.

At least in octave 3.0.5 it seems intersect works on vectors but not matrices.
However, on the same help page for `intersect' I've found `ismember' which does what I need:
ismember( A, B, "rows" ).

Cheers

--- On Mon, 25/1/10, Jaroslav Hajek <address@hidden> wrote:

From: Jaroslav Hajek <address@hidden>
Subject: Re: Comparing vectors
To: address@hidden
Cc: "Octave mai. lis." <address@hidden>
Date: Monday, 25 January, 2010, 5:51 PM



On Mon, Jan 25, 2010 at 6:14 AM, Mike B. <address@hidden> wrote:
Hi All,

Would appreciate help cracking this:

I have two matrices of row vectors  A ( n X d ) and B ( m X d ), n>m . In both matrices the vectors are binary, that is, each component is either 0 or 1.

What is an efficient way to find which vectors from B are already in A, for example,
A( 2, : ) equals B( 4, : ) etc. For each row in B I need the corresponding row from A.

Thanks,
Mike.



[C, I]  = intersect (B, A, "rows");

--
RNDr. Jaroslav Hajek, PhD
computing expert & GNU Octave developer
Aeronautical Research and Test Institute (VZLU)
Prague, Czech Republic
url: www.highegg.matfyz.cz


New Email addresses available on Yahoo!
Get the Email name you've always wanted on the new @ymail and @rocketmail.
Hurry before someone else does!
reply via email to

[Prev in Thread] Current Thread [Next in Thread]