Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: Problem using horzcat with index vectors in a for loop
Replies: 7   Last Post: Jan 22, 2013 6:45 AM

 Messages: [ Previous | Next ]
 Bruno Luong Posts: 9,822 Registered: 7/26/08
Re: Problem using horzcat with index vectors in a for loop
Posted: Jan 21, 2013 8:06 AM

"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

Date Subject Author
1/21/13 Bruno Luong
1/21/13 Bruno Luong
1/22/13 NoLi
1/22/13 Bruno Luong
1/22/13 Bruno Luong