"Hist" is a short for "histogram (histogram, bar chart)".
1.N = hist (Y)
Bins the elements of Y into ten equally spaced containers and returns the number of elements in each Container. If Y is a matrix, hist works down the columns.
(The elements of vector y are averaged into containers of 10 equal intervals, and the number of elements per container is returned.) If Y is a matrix, the hist directive operates on a column-by-element basis. The case of the Y vector is shown in examples 1 and 2, for the case of the matrix see Example 3.)
Example 1. Execution Instructions
>> Y = [1:10];
>> hist (Y)
Get
10 blue bars, each of which corresponds to a container whose length represents the amount of data in the container. By graph, the amount of data in the container is 1. This example is not typical, see Example 2.
Example 2. Execution instructions
>> Y = [1, 2, 2, 5, 6, 6, 8, 11];
>> hist (Y)
Get
Y Maximum is 11 and the minimum is 1, thereforeThe interval [1,11] is divided into 10 points, respectively [1, 2],(2,3], (3,4],(4,5],(5,6], (6,7], (7,8], (8,9], (9,10], (10,11].
Example 3. When Y is a matrix.
Execution Instructions:
>> Y = [1,2.5,2.1;3,3.5,6];
>> hist (Y)
Note that Y is a matrix:
1.0000 2.5000 2.1000
3.0000 3.5000 6.0000
Y has three columns of elements, and column-wise elements produce corresponding histograms. Get
Observing this graph and the matrix y, because the element of Y is maximum 1 and the minimum is 6, the interval [1,6] is divided into 0.5 intervals as 10 equal-length sub-ranges as 10 containers to accommodate the data. The square bars in the figure are three colors: blue, green, and red, corresponding to the 1th, 2, and 3 column elements in Y respectively. For example, the first column elements are 1 and 3, so the bands [1,1.5] and (2.5,3) have blue square bars.
2.N = hist (y,m)
where M is a scalar, uses M bins. (M is a scalar that indicates the use of M-boxes )
Example 1. Execution instructions
>> Y = [1, 1, 1.3, 2.6, 3, 3.4, 5, 5.9, 6, 6, 1, 7, 7,2];
>> hist (Y, 6)
Get
3.N = hist (y,x)
where x is a vector, returns the distribution of Y among bins with centers specified by X.(x is a vector, the element in X is the interval center to obtain a series of intervals, perform command to obtain the distribution of y in these intervals. The first bin includes data Between-inf and the first center and the last bin includes data between the last bin a nd INF. note:use HISTC if it is more natural to specify bin edges instead.
Using MATLAB to realize frequency histogram--hist