Main Content

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.**

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`