Note: This page has been translated by MathWorks. Please click here

To view all translated materials including this page, select Japan from the country navigator on the bottom of this page.

To view all translated materials including this page, select Japan from the country navigator on the bottom of this page.

Histogram bin counts

```
[N,edges]
= histcounts(X)
```

```
[N,edges]
= histcounts(X,nbins)
```

```
[N,edges]
= histcounts(X,edges)
```

```
[N,edges,bin]
= histcounts(___)
```

`N = histcounts(C)`

`N = histcounts(C,Categories)`

```
[N,Categories]
= histcounts(___)
```

`[___] = histcounts(___,Name,Value)`

`[`

partitions the `N`

,`edges`

]
= histcounts(`X`

)`X`

values
into bins, and returns the count in each bin, as well as the bin edges.
The `histcounts`

function uses an automatic binning
algorithm that returns bins with a uniform width, chosen to cover
the range of elements in `X`

and reveal the underlying
shape of the distribution.

counts
only the elements in `N`

= histcounts(`C`

,`Categories`

)`C`

whose value is equal to
the subset of categories specified by `Categories`

.

`[`

also returns the categories
that correspond to each count in `N`

,`Categories`

]
= histcounts(___)`N`

using either
of the previous syntaxes for categorical arrays.

`[___] = histcounts(___,`

uses
additional options specified by one or more `Name,Value`

)`Name,Value`

pair
arguments using any of the input or output argument combinations in
previous syntaxes. For example, you can specify `'BinWidth'`

and
a scalar to adjust the width of the bins for numeric data. For categorical
data, you can specify `'Normalization'`

and either `'count'`

, `'countdensity'`

, `'probability'`

, `'pdf'`

, `'cumcount'`

,
or `'cdf'`

.

The behavior of

`histcounts`

is similar to that of the`discretize`

function. Use`histcounts`

to find the number of elements in each bin. On the other hand, use`discretize`

to find which bin each element belongs to (without counting).

Was this topic helpful?