Labfans是一个针对大学生、工程师和科研工作者的技术社区。 论坛首页 | 联系我们(Contact Us)
MATLAB爱好者论坛-LabFans.com
返回   MATLAB爱好者论坛-LabFans.com > 工程数学软件 > MATLAB论坛
MATLAB论坛 一切MATLAB相关问题在此讨论。
回复
 
主题工具 显示模式
旧 2009-05-17, 10:59   #1
ljlj521521521
初级会员
 
注册日期: 2009-04-18
帖子: 20
声望力: 17
ljlj521521521 正向着好的方向发展
默认 hist 绘制直方图函数用法

语法:

n = hist(Y)
n = hist(Y,x)
n = hist(Y,nbins)
[n,xout] = hist(...)
hist(...)
hist(axes_handle,...)

描述:

直方图显示了数据值的分布情况。
n = list(Y)
将向量Y中的元素分到10个等间隔的范围内,并返回每个范围内元素的个数作为一行向量。
如果Y是一个m x p的矩阵,hist将Y的每一列作为一个向量,并返回一个10 x p的矩阵n。n的每一列的值对应Y的该列。
n = hist(Y, x)
x是一个向量,返回x的长度个以x为中心的,Y的分布情况。
例如:如果x是一个5元素的向量,返回Y在以x为中心的,x长度个范围内数据直方分布。
注:如果更需要制定数值边界而不是中心,可以使用histc。
n = hist(Y, nbins)
nbins是一个范围,使用nbins间隔数。
[n,xout] = hist(...)
返回n和xout,包含有数目频率和间隔位置。可以使用bar(xout, n)来绘制直方图。
hist(...)
使用上述方法绘制没有输出的直方图。
hist(axes_handle)
使用exes_handle轴绘制,代替目前的轴(gca)。



------------------------------------------------------------

hist :Histogram plot

Syntax

n = hist(Y)
n = hist(Y,x)
n = hist(Y,nbins)
[n,xout] = hist(...)
hist(...)
hist(axes_handle,...)

Description

A histogram shows the distribution of data values.

n = hist(Y) bins the elements in vector Y into 10 equally spaced containers and returns the number of elements in each container as a row vector. If Y is an m-by-p matrix, hist treats the columns of Y as vectors and returns a 10-by-p matrix n. Each column of n contains the results for the corresponding column of Y.

n = hist(Y,x) where x is a vector, returns the distribution of Y among length(x) bins with centers specified by x. For example, if x is a 5-element vector, hist distributes the elements of Y into five bins centered on the x-axis at the elements in x. Note: use histc if it is more natural to specify bin edges instead 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 frequency counts and the bin locations. You can use bar(xout,n) to plot the histogram.

hist(...) without output arguments produces a histogram plot of the output described above. hist distributes the bins along the x-axis between the minimum and maximum values of Y.

hist(axes_handle,...) plots into the axes with handle axes_handle instead of the current axes (gca).

Remarks

All elements in vector Y or in one column of matrix Y are grouped according to their 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-axis shows the number of elements that fall within the groups; therefore, the y-axis ranges 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 change the color of the graph, you can set patch properties. See the "Example" section for more information. By default, the graph color is controlled by the current colormap, which maps the bin color to the first color in the colormap.

Examples

Generate a bell-curve histogram from Gaussian data.

代码:

x = -2.9:0.1:2.9;
y = randn(10000,1);
hist(y,x)
Change the color of the graph so that the bins are red and the edges of the bins are white.

代码:

h = findobj(gca,'Type','patch');
set(h,'FaceColor','r','EdgeColor','w')
ljlj521521521 当前离线   回复时引用此帖
旧 2009-05-17, 11:08   #2
silas_xue
高级会员
 
注册日期: 2008-11-01
年龄: 39
帖子: 406
声望力: 26
silas_xue 是一个将要出名的人
默认 回复: hist 绘制直方图函数用法

无论是转帖还是原创 感谢
这样的翻译举动会让更多的网友熟悉matlab函数的用法
支持一下
silas_xue 当前离线   回复时引用此帖
回复


发帖规则
不可以发表新主题
不可以发表回复
不可以上传附件
不可以编辑自己的帖子

启用 BB 代码
论坛启用 表情符号
论坛启用 [IMG] 代码
论坛禁用 HTML 代码



所有时间均为北京时间。现在的时间是 14:04


Powered by vBulletin
版权所有 ©2000 - 2025,Jelsoft Enterprises Ltd.