Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

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


Math Forum » Discussions » Software » comp.soft-sys.matlab

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

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Bruno Luong

Posts: 8,845
Registered: 7/26/08
Re: Problem using horzcat with index vectors in a for loop
Posted: Jan 21, 2013 8:06 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

"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



Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.