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
|