Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Finding positions of the entries of one vector in another

Status
Not open for further replies.

hoopz

Electrical
Sep 22, 2006
7
US
I'm converting some code from R and I'm having trouble with a line of code that I feel like there should be a built in function for in Matlab. In R, the function is:

match(x,table)

which returns a vector of the positions of (first) matches of its first argument in its second.

So if I have two vectors:
V1 = {1,2,3,4,5,6}
V2 = {3,4,2,1,5,6}

then match(V1,V2) will return:

{4,3,1,2,5,6}


Anyone know a way I can do this same thing in Matlab without having to write my own function?

Thanks!
 
Replies continue below

Recommended for you

Have a look at the "intersect" function.

M

--
Dr Michael F Platten
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top