This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.


Modal (most frequent) value(s) in a data sample

MuPAD® notebooks are not recommended. Use MATLAB® live scripts instead.

MATLAB live scripts support most MuPAD functionality, though there are some differences. For more information, see Convert MuPAD Notebooks to MATLAB Live Scripts.


stats::modal(x1, x2, …)
stats::modal([x1, x2, …])
stats::modal(s, <c>)


stats::modal(x1, x2, …) returns the most frequent value(s) of the data xi.

The column index c is optional, if the data are given by a stats::sample object containing only one non-string column. Cf. Example 3.

External statistical data stored in an ASCII file can be imported into a MuPAD® session via import::readdata. In particular, see Example 1 of the corresponding help page.



x1, x2, …

The statistical data: arithmetical expressions.


A sample of domain type stats::sample.


An integer representing a column index of the sample s. This column provides the data x1, x2 etc.

Return Values

Sequence consisting of a list and an integer. The list contains the most frequent element(s) in the data, the integer specifies the number of occurrences. E.g., the result [x5, x10], 21 means that x5 and x10 are the most frequent data items, each occurring 21 times.

Was this topic helpful?