Skip to content
This repository was archived by the owner on May 21, 2020. It is now read-only.

histogram

Florian Rappl edited this page Dec 21, 2014 · 2 revisions

histogram

Computes a histogram that shows the distribution of data values.

histogram(Y)

Bins the elements in vector Y into 10 equally spaced containers and outputs the number of elements in each container in a row vector. If Y is an m-by-p matrix, histogram treats the columns of Y as vectors and outputs a 10-by-p matrix n. Each column of n contains the results for the corresponding column of Y. No elements of Y can be complex or of type integer.

Argument Y

Matrix

Returns 1. entry

Matrix

Example

histogram(rand(100, 1))

Places 100 uniformly generated random numbers into 10 bins with a spacing that should be approximately 0.1.

histogram(Y,x)

Here x is a vector, such that the distribution of Y among length(x) bins with centers specified by x. For example, if x is a 5-element vector, histogram distributes the elements of Y into five bins centered on the x-axis at the elements in x, none of which can be complex.

Argument Y

Matrix

Argument x

Matrix

Returns 1. entry

Matrix

Example

histogram(rand(100, 1), [0.1, 0.5, 0.9])

Places 100 uniformly generated random numbers into 3 bins that center around 0.1, 0.5 and 0.9.

histogram(Y,nbins)

Bins the elements in vector Y into nbins equally spaced containers and outputs the number of elements as before.

Argument Y

Matrix

Argument nbins

Scalar

Returns 1. entry

Matrix

Example

histogram(rand(100, 1), 20)

Places 100 uniformly generated random numbers into 20 bins with a spacing that should be approximately 0.05.

Clone this wiki locally