On Mon, 25 Jan 2010 16:10:12 +0800, <
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.
I've found a simple solution. However, I've no idea whether there is a simpler one.
for r=m:-1:1
myans{r}=find(all(repmat(B(1,:),n,1)==A,2));
end
--Best Regards!
---------------------------
Sincerely, Chengqi Zhang
China Center for Economic Research
Mail:
address@hiddenPersonal Website:
http://macro2.cn