%% Mode of Matrix Rows with Frequency and Multiplicity Information
% Define a 3-by-4 matrix.

A = [3 3 1 4; 0 0 1 1; 0 1 2 4]

%
% Find the most frequent value of each row, how often it occurs, and which values in that row occur with the same frequency.

[M,F,C] = mode(A,2)

% C{2} is the 2-by-1 vector [0;1] since values 0 and 1 in the second row occur with frequency F(2).
% C{3} is the 4-by-1 vector [0;1;2;4] since all values in the third row occur with frequency F(3).
% Copyright 2012 The MathWorks, Inc.