Note: This page has been translated by MathWorks. Click here to see

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

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

Histogram bin counts (not recommended; use `histcounts`

)

`histc`

is not recommended. Use `histcounts`

instead.

**For more information, including suggestions on updating code,
see Replace Discouraged Instances of hist and histc.**

`bincounts = histc(x,binranges)`

`bincounts = histc(x,binranges,dim)`

```
[bincounts,ind]=
histc(___)
```

counts
the number of values in `bincounts`

= histc(`x`

,`binranges`

)`x`

that are within each
specified bin range. The input, `binranges`

, determines
the endpoints for each bin. The output, `bincounts`

,
contains the number of elements from `x`

in each
bin.

If

`x`

is a vector, then`histc`

returns`bincounts`

as a vector of histogram bin counts.If

`x`

is a matrix, then`histc`

operates along each column of`x`

and returns`bincounts`

as a matrix of histogram bin counts for each column.

To plot the histogram, use `bar(binranges,bincounts,'histc')`

.

If values in

`x`

lie outside the specified bin ranges, then`histc`

does not include these values in the bin counts. Start and end the`binranges`

vector with`-inf`

and`inf`

to ensure that all values in`x`

are included in the bin counts.

`bar`

| `hist`

| `histcounts`

| `histogram`

| `mode`

Was this topic helpful?