How to display labels above a histogram bin?

前端 未结 3 636
暖寄归人
暖寄归人 2020-12-18 07:02

I have an array a(30,2) where the first column is a unique sample number and the second column is a value assigned to the sample. I plot a histogram of the 2nd

3条回答
  •  忘掉有多难
    2020-12-18 07:10

    Use histc, which return an index for each entry, to which bin did it 'fall':

    [n, bin] = histc (a(:, 2), bins);

    Then the samples above the k'th bin is:

    a(bin==k, 1);

    Pay attention, you must specify the bins' boundaries yourself (unlike hist which uses the mid-value between boundaries).

提交回复
热议问题