Statistical Mode

Finds the "mode" (most occuring element) in a 1D number REAL array

Al momento, stai seguendo questo contributo

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!

Cita come

Muneem Shahriar (2026). Statistical Mode (https://it.mathworks.com/matlabcentral/fileexchange/6822-statistical-mode), MATLAB Central File Exchange. Recuperato .

Informazioni generali

Compatibilità della release di MATLAB

  • Compatibile con qualsiasi release

Compatibilità della piattaforma

  • Windows
  • macOS
  • Linux
Versione Pubblicato Note della release Action
1.0.0.0

Found a small bug the other night, corrected the problem with index in finding mode.