MATLAB Function Reference (Volume 2: Graphics)

MATLAB Function Reference (Volume 2: Graphics) MATLAB Function Reference (Volume 2: Graphics)

12.07.2015 Views

histPurpose2histHistogram plotSyntaxDescriptionn = hist(Y)n = hist(Y,x)n = hist(Y,nbins)[n,xout] = hist(...)A histogram shows the distribution of data values.n = hist(Y) bins the elements in Y into 10 equally spaced containers andreturns the number of elements in each container. If Y is a matrix, hist worksdown the columns.n = hist(Y,x) where x is a vector, returns the distribution of Y amonglength(x) bins with centers specified by x. For example, if x is a 5-elementvector, hist distributes the elements of Y into five bins centered on the x-axisat the elements in x. Note: use histc if it is more natural to specify bin edgesinstead of centers.n = hist(Y,nbins) where nbins is a scalar, uses nbins number of bins.[n,xout] = hist(...) returns vectors n and xout containing the frequencycounts and the bin locations. You can use bar(xout,n) to plot the histogram.hist(...) without output arguments, hist produces a histogram plot of theoutput described above. hist distributes the bins along the x-axis between theminimum and maximum values of Y.RemarksAll elements in vector Y or in one column of matrix Y are grouped according totheir numeric range. Each group is shown as one bin.The histogram’s x-axis reflects the range of values in Y. The histogram’s y-axisshows the number of elements that fall within the groups; therefore, the y-axisranges from 0 to the greatest number of elements deposited in any bin.The histogram is created with a patch graphics object. If you want to changethe color of the graph, you can set patch properties. See the “Example” sectionfor more information. By default, the graph color is controlled by the currentcolormap, which maps the bin color to the first color in the colormap.2-222

histExamplesGenerate a bell-curve histogram from Gaussian data.x = –2.9:0.1:2.9;y = randn(10000,1);hist(y,x)400350300250200150100500−3 −2 −1 0 1 2 32-223

histPurpose2histHistogram plotSyntaxDescriptionn = hist(Y)n = hist(Y,x)n = hist(Y,nbins)[n,xout] = hist(...)A histogram shows the distribution of data values.n = hist(Y) bins the elements in Y into 10 equally spaced containers andreturns the number of elements in each container. If Y is a matrix, hist worksdown the columns.n = hist(Y,x) where x is a vector, returns the distribution of Y amonglength(x) bins with centers specified by x. For example, if x is a 5-elementvector, hist distributes the elements of Y into five bins centered on the x-axisat the elements in x. Note: use histc if it is more natural to specify bin edgesinstead of centers.n = hist(Y,nbins) where nbins is a scalar, uses nbins number of bins.[n,xout] = hist(...) returns vectors n and xout containing the frequencycounts and the bin locations. You can use bar(xout,n) to plot the histogram.hist(...) without output arguments, hist produces a histogram plot of theoutput described above. hist distributes the bins along the x-axis between theminimum and maximum values of Y.RemarksAll elements in vector Y or in one column of matrix Y are grouped according totheir numeric range. Each group is shown as one bin.The histogram’s x-axis reflects the range of values in Y. The histogram’s y-axisshows the number of elements that fall within the groups; therefore, the y-axisranges from 0 to the greatest number of elements deposited in any bin.The histogram is created with a patch graphics object. If you want to changethe color of the graph, you can set patch properties. See the “Example” sectionfor more information. By default, the graph color is controlled by the currentcolormap, which maps the bin color to the first color in the colormap.2-222

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!