%% Unequal Numbers of Rows and Columns
% Match rows to columns when you have many more columns than rows in the cost matrix.
%
% Create a 3-by-8 cost matrix. Since you have only three rows, matchpairs can produce at most three matches with the eight columns.

rng default % for reproducibility
C = randi([10 100], 3, 8)

%
% Use matchpairs to match the rows and columns of the cost matrix. To get the maximum number of matches, use a large cost of unassignment (relative to the magnitude of the entries in the cost matrix). Specify three outputs to return the indices of unmatched rows and columns.

[M,uR,uC] = matchpairs(C,1e4)

% Five of the columns in C are not matched with any rows.
%
% Copyright 2018 The MathWorks, Inc.