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: Using Intersect Without Removing Repetitions
Replies: 3   Last Post: Aug 24, 2015 7:09 AM

Advanced Search

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

Posts: 1,268
Registered: 10/24/08
Re: Using Intersect Without Removing Repetitions
Posted: Jan 10, 2013 8:01 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

"zcbtf89" wrote in message <kcm7q0$m1u$1@newscl01ah.mathworks.com>...
> I would like to do the following:
> [C ind] = intersect(A,B);
> Where A(100,1), is a vector with a list of consecutive values from 1 to 1000 in a random order (i.e. value 3 is in row 11),
> And B (5,1) is a vector with a shorter list of values all of which occur in A at some location. However there are some repetitions i.e. [1 3 5 5 70] ...
> I would like my output vector 'ind' to account for these repetitions in B, such that the index in A repeats itself. i.e. for the above example ind = [ 1 11 25 25 100].
> Any help regarding this would be much appreciated,
> Thanks!

I think ISMEMBER can do that for you

[tf,ind] = ismember(B,A)

~ Jos

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

[Privacy Policy] [Terms of Use]

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