MATLAB实现频数表——hist的使用

借助命令hist,matlab可以通过两个方式实现频数表。

1.[f, xout] = hist(X)

将数据向量X的取值范围均分为10个区间,统计频数,返回频数向量f和区间中点行向量xout.

例1.

执行指令

>> X = [1, 1.2, 1.3, 2, 3, 3.2, 3.5, 4, 4.5, 5, 6];
>> [f, xout] = hist(X)

得到

f =
     3     1     0     1     2     1     1     1     0     1
xout =
    1.2500    1.7500    2.2500    2.7500    3.2500    3.7500    4.2500    4.7500    5.2500    5.7500

2.[f, xout] = hist(x, k)

将数据向量X的取值范围均分为k个区间,统计频数,返回频数向量f和区间中点行向量xout.

原文地址:https://www.cnblogs.com/cszlg/p/2910418.html