Define a 3-by-4 matrix.

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

X =
3 3 1 4
0 0 1 1
0 1 2 4

Find the most frequent value of each column.

M = mode(X)

M =
0 0 1 4

Define a 3-by-4 matrix.

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

X =
3 3 1 4
0 0 1 1
0 1 2 4

Find the most frequent value of each row.

M = mode(X,2)

M =
3
0
0

Create a 1-by-3-by-4 array of integers between `1` and `10`.

X = gallery('integerdata',10,[1,3,4],1)

X(:,:,1) =
10 8 10
X(:,:,2) =
6 9 5
X(:,:,3) =
9 6 1
X(:,:,4) =
4 9 5

Find the most frequent values of this 3-D array along
the second dimension.

M = mode(X)

M(:,:,1) =
10
M(:,:,2) =
5
M(:,:,3) =
1
M(:,:,4) =
4

This operation produces a 1-by-1-by-4 array by finding the most
frequent value along the second dimension. The size of the second
dimension reduces to `1`.

Compute the mode along the first dimension of `X`.

M = mode(X,1);
isequal(X,M)

ans =
1

This returns the same array as `X` because
the size of the first dimension is `1`.

Define a 3-by-4 matrix.

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

X =
3 3 1 4
0 0 1 1
0 1 2 4

Find the most frequent value of each column, as well as
how often it occurs.

[M,F] = mode(X)

M =
0 0 1 4
F =
2 1 2 2

`F(1)` is `2` since `M(1)` occurs
twice in the first column.

Define a 3-by-4 matrix.

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

X =
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(X,2)

M =
3
0
0
F =
2
2
1
C =
[ 3]
[2x1 double]
[4x1 double]

`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)`.

Define a 1-by-4 vector of 16-bit unsigned integers.

X = gallery('integerdata',10,[1,4],3,'uint16')

X =
6 3 2 3

Find the most frequent value, as well as the number of
times it occurs.

[M,F] = mode(X),
class(M)

M =
3
F =
2
ans =
uint16

`M` is the same class as the input, `X`.