Mode function for MATLAB 6.1 or above
Syntax: [mode,modal,times] = ms_modal(x);
where :
x is the 1-D input array consisting of REAL numbers, in either row or columnar form modal is the output which consists of the numbers appearing in array x. It has each number once only. This is not sorted.
times is the array which records how many times each corresponding number in modal occurs
Example:
x = [1 2 3 4 1 1 2]
[mode,modal,times] = ms_modal(x);
gives:
mode = 1
modal =
1 2 3 4 0 0
times =
3 2 1 1 0 0
Created by Muneem Shahriar (muneem.shahriar@ttu.edu)
*************************************
LIMITATION: ONLY OUTPUTS 1 ELEMENT AS THE MODE.
Let me know if you run into problems! |