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.

Bin Data

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.

The stats::frequency function categorizes the numerical data into a number of bins given by semiopen intervals (ai, bi]. This function returns a table with the entries (rows) corresponding to the bins. Each entry shows the following information:

  • The number of the bin

  • The interval defining the bin

  • The number of data in the bin

  • The data contained in the bin

The stats::frequency function enables you to specify the number of bins. By default, stats::frequency categorizes the data into 10 bins. For example, categorize the following data into 10 bins:

x := [-10.1, -1, 1.1, 3.5, 13, 0, -5.5, 0.5,
                   7.9, 15, 0.15, 6.7, 2, 9]:

Now, categorize the same data into 5 bins:

stats::frequency(x, 5)

When creating the bins, you can specify the intervals. For example, divide the data into two bins: one bin contains the numbers that are less or equal to zero, and the other bin contains the numbers that are greater than zero:

stats::frequency(x, [[-infinity, 0], [0, infinity]])

For graphical interpretation of the data binning, see Create Bar Charts, Histograms, and Pie Charts.

Was this topic helpful?