Effacer les filtres
Effacer les filtres

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

3 vues (au cours des 30 derniers jours)
Wenlong
Wenlong le 3 Avr 2012
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

Réponses (1)

Wayne King
Wayne King le 3 Avr 2012
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);

Tags

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by