Main Content

本页翻译不是最新的。点击此处可查看最新英文版本。

fewerbins

减少直方图 bin 数量

说明

示例

N = fewerbins(h) 将直方图 h 中的 bin 数量减少 10%(向下四舍五入为最近的整数),并返回新的 bin 数量。

对于二元直方图,这会减少 x 和 y 这两个方向的 bin 计数。

N = fewerbins(h,direction)(其中 h 必须是 histogram2 对象)仅会减少 direction 指定的维度中的 bin 数量。direction 选项可以是 'x''y''both'。默认值为 'both'

示例

全部折叠

绘制由 1,000 个随机数构成的直方图并返回直方图对象的句柄。

x = randn(1000,1);
h = histogram(x)

Figure contains an axes object. The axes object contains an object of type histogram.

h = 
  Histogram with properties:

             Data: [1000x1 double]
           Values: [3 1 2 15 17 27 53 79 85 101 127 110 124 95 67 32 27 16 6 6 4 1 2]
          NumBins: 23
         BinEdges: [-3.3000 -3.0000 -2.7000 -2.4000 -2.1000 -1.8000 -1.5000 -1.2000 -0.9000 -0.6000 -0.3000 0 0.3000 0.6000 0.9000 1.2000 1.5000 1.8000 2.1000 2.4000 2.7000 3 3.3000 3.6000]
         BinWidth: 0.3000
        BinLimits: [-3.3000 3.6000]
    Normalization: 'count'
        FaceColor: 'auto'
        EdgeColor: [0 0 0]

  Use GET to show all properties

使用 fewerbins 减少直方图中的 bin 数量。

fewerbins(h);
fewerbins(h)

Figure contains an axes object. The axes object contains an object of type histogram.

ans = 18

输入参数

全部折叠

输入直方图,指定为 histogramhistogram2 对象。

h 不能是分类直方图。

减少 bin 数量的方向,指定为 'x''y''both'。指定 'x''y' 仅会减少该方向的 bin 数量,而另一方向中的 bin 数量保持不变。

输出参数

全部折叠

bin 数量,以标量或向量形式返回。N 是增加后的新的直方图的 bin 数量。对于二元直方图,N 是二元素向量 [nx ny]

版本历史记录

在 R2014b 中推出