Code covered by the BSD License  

Highlights from
FINDIND

Be the first to rate this file! 0 Downloads (last 30 days) File Size: 2.53 KB File ID: #22786

FINDIND

by Jos (10584)

 

26 Jan 2009 (Updated 27 Jan 2009)

find indices of matching elements between two matrices (v2.0, jan 09)

| Watch this File

File Information
Description

  FINDIND - find indices of matching elements between two matrices
 
    IB = FINDIND(A,B) returns a cell array IB which has the same size as A.
    Each cell of IB contains a row vector with the indices of those elements
    of B that are equal to the corresponding element of A. In other words,
    for each k, IB{k} equals "find(B == A(k))".
 
    [IB, IA] = FINDIND(A,B) also return another cell array IA holding the
    indices of those elements of A that are equal to the corresponding
    element of B. In other words, for each k, IA{k} equals "find(A == B(k))".
 
    A and B may have repeated elements. If an element of A or B is not
    present in B or A, the corresponding cell will be empty. A and B can be
    cell array of strings.
 
    Example:
       A = [1 4 2 ; 3 4 5] ;
       B = [1 2 1 1 4 2 2 2 4 5 5] ;
       x = findind(A,B)
       % -> x = {[ 1 3 4 ], [ 5 9 ], [ 2 6 7 8 ]
       % [] , [ 5 9 ], [10 11] }
 
    See also find, ismember, unique

MATLAB release MATLAB 7.6 (R2008a)
Other requirements Should work on most ML releases (uses BSXFUN or REPMAT)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Please login to add a comment or rating.
Updates
27 Jan 2009

Now can also return indices into first argument; fixed bug when no matches were found.

Tag Activity for this File
Tag Applied By Date/Time
indices Jos (10584) 26 Jan 2009 15:50:17
find Jos (10584) 26 Jan 2009 15:50:17
match Jos (10584) 26 Jan 2009 15:50:17
ismember Jos (10584) 26 Jan 2009 15:50:17
count Jos (10584) 26 Jan 2009 15:50:17

Contact us at files@mathworks.com