Path: news.mathworks.com!not-for-mail
From: "Bruno Luong" <b.luong@fogale.findmycountry>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Problem using horzcat with index vectors in a for loop
Date: Mon, 21 Jan 2013 13:06:08 +0000 (UTC)
Organization: FOGALE nanotech
Lines: 40
Message-ID: <kdjeg0$l$1@newscl01ah.mathworks.com>
References: <kdhu6v$o6p$1@newscl01ah.mathworks.com>
Reply-To: "Bruno Luong" <b.luong@fogale.findmycountry>
NNTP-Posting-Host: www-01-blr.mathworks.com
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: newscl01ah.mathworks.com 1358773568 21 172.30.248.46 (21 Jan 2013 13:06:08 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Mon, 21 Jan 2013 13:06:08 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 390839
Xref: news.mathworks.com comp.soft-sys.matlab:786987

"Thomas " <thomas.seers@postgrad.manchester.ac.uk> wrote in message <kdhu6v$o6p$1@newscl01ah.mathworks.com>...
> Hi 
> I am trying to horizontally concatenate identical rows identified from two matrices using index vectors obtained using intersect: E.g. 
> A =
>      2     4
>      5     7
>      2     8
>      3     1
>      8     4
> B =
>      5     7
>      2     4
>      2     2
>      8     4
>      3     1
> [C,ia,ib] = intersect(A,B,'rows', 'legacy');
> C =
> 
>      2     4
>      3     1
>      5     7
>      8     4
> ia =
>      1
>      4
>      2
>      5
> 
> ib =
>      2
>      5
>      1
>      4
> 
> So I want to use the vector indices (ia / ib) to horizontally concatenate the matched rows found using intersect. E.g. for the first identified row this would be:
>  D =  horzcat(A(ia(1),:), B(ib(1),:))

Please post your whole code (with ismember) and short example of desired output. It sounds like you just concatenate two times C together.

Bruno