mode( ) command or function gives the most repeated element of vector or matrix or array elements, after reading this MATLAB mode topic, you will know the theory and examples.
Syntax:
mode(n)
- n can be a vector or matrix.
Example: To find the most repeated vector element.
n=[1,2,2,10,5,78] mode(n)
Output:
n = 1 2 2 10 5 78 ans = 2
Example: To find the most repeated elements of each column of the matrix.
n=[1,2,3;1,2,8;4,5,8] mode(n)
Output:
n = 1 2 3 1 2 8 4 5 8 ans = 1 2 8
Explanation:
- 1, 2 and 8 are the mode values of the first, second and third column elements respectively.