mfind

Find matching rows or columns in a matrix
852 Downloads
Updated 20 Jan 2014

View License

%MFIND Find matching rows or columns in a matrix
%
% I = mfind(M, X, mode = 'rows' | dim = 2)
%
% mode = rows (dim = 2, default)
% Find rows in matrix M matching the row-vector X.
% I will contain M's row indexes.
%
% mode = 'cols' (dim = 1)
% Find columns in matrix M matching column-vetor X.
% I will contain M's column indexes.
%
% If no match is found, I will be empty.
%
% Example:
% a = [1 2; 3 4; 5 6];
%
% i = mfind(a, [3 4]); % i = 2;
%
% i = mfind(a, [1; 3; 5], 'cols'); % i = 1;
%
% Copyright 2011-2014
%
% v1.2.0 - 29/03/2011 - 16/01/2014
% Marcello Ferro <marcello.ferro@ilc.cnr.it>
% http://www.ilc.cnr.it
%

Cite As

Marcello Ferro (2024). mfind (https://www.mathworks.com/matlabcentral/fileexchange/30875-mfind), MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2009b
Compatible with any release
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Version Published Release Notes
1.2.0.0

Code is now 50 times faster, as ismember was replaced with bsxfun.

1.1.0.0

v1.0.1 Minor corrections in help section
v1.0.0 First release

1.0.0.0