%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 (2026). mfind (https://uk.mathworks.com/matlabcentral/fileexchange/30875-mfind), MATLAB Central File Exchange. Retrieved .
MATLAB Release Compatibility
Platform Compatibility
Windows macOS LinuxCategories
Tags
Discover Live Editor
Create scripts with code, output, and formatted text in a single executable document.
