主要内容

morebins

R2026b

增加直方图的箱数

描述

N = morebins(h) 将直方图 h 中箱数增加 10%(向上四舍五入为最近的整数),并返回新的箱数。

对于二元直方图,这会增加 x 和 y 方向的箱数。

示例

N = morebins(h,direction)(其中 h 必须是 histogram2 对象)只会增加 direction 指定的维度中的箱数。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: [1000×1 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.1294 0.1294 0.1294]

  Show all properties

使用 morebins 增加直方图中的箱数。

morebins(h);
morebins(h)

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

ans = 
29

输入参数

全部折叠

输入直方图,指定为 histogram 或 histogram2 对象。

h 不能是分类直方图。

要增加箱数的方向,指定为 'x'、'y' 或 'both'。指定 'x' 或 'y' 以仅增加该方向的箱数,其他方向的箱数保持不变。

输出参量

全部折叠

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

版本历史记录

在 R2014b 中推出