How to get the number of samples of each bar in histogram?

3 次查看(过去 30 天)
Dear all,
I have a mxn matrix where has n samples and each of them have m variables. I use hist(x, 20) to build histograms on each of the n samples.
Now I want to find how many variables that each bar in a histogram contains. What command should I used to achieve this automatically?
Thank you very much for your help.
Best wishes
Long

回答(1 个)

Wayne King
Wayne King 2012-4-3
Use the output arguments
x = randn(1e3,1);
N = hist(x,20);
N gives you a vector of counts (frequencies) in each bin. If you want the bin centers as well.
[N,bincentr] = hist(x,20);

类别

Help CenterFile Exchange 中查找有关 Histograms 的更多信息

标签

产品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by