Statistical Mode
No License
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!
Cite As
Muneem Shahriar (2024). Statistical Mode (https://www.mathworks.com/matlabcentral/fileexchange/6822-statistical-mode), MATLAB Central File Exchange. Retrieved .
MATLAB Release Compatibility
Platform Compatibility
Windows macOS LinuxCategories
Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Discover Live Editor
Create scripts with code, output, and formatted text in a single executable document.
Version | Published | Release Notes | |
---|---|---|---|
1.0.0.0 | Found a small bug the other night, corrected the problem with index in finding mode. |