FUNCTION REFERENCE

mode

Most frequent value.

Most frequent value.

Syntax

M = mode(X)

Syntax

M = mode(X, dim)

Syntax

[M, F] = mode(X)

F counts how often M occurs. Ties give the smallest value. NaN values are

never counted as repeats. The empty input gives NaN.

Logical and char input give a logical or char M.

Example

[m, f] = mode([1 2 2 3 3])   % m = 2, f = 2

Differences from MATLAB: the third output (cell of all tied values) is not

supported yet. Complex input orders by abs, then angle, and returns the first most frequent value in that order.

These are the engine’s help pages. Each page keeps its compatibility notes. File operations are unavailable in the browser.