Histogram with log Bin width

120 ビュー (過去 30 日間)
Markus Similä
Markus Similä 2020 年 8 月 3 日
編集済み: Markus Similä 2020 年 8 月 6 日
I have a single column vector with values ranging from 0 to about 400 000.
I need to make a histogram from this data, which has a logarithmically changing bin size.
The height values in each bin should also be divided with the corresponding bins width.
How can this be done?
Advice would be appreciated,
Thanks

採用された回答

Sean de Wolski
Sean de Wolski 2020 年 8 月 3 日
x = rand(1,10000)*100000;
bins = 10.^(0:5);
histogram(x, bins);
set(gca, "XScale", "log")
  1 件のコメント
Markus Similä
Markus Similä 2020 年 8 月 4 日
Thanks!
This sort of works. But does it divide the values by the width of each bin?

サインインしてコメントする。

その他の回答 (1 件)

Markus Similä
Markus Similä 2020 年 8 月 6 日
編集済み: Markus Similä 2020 年 8 月 6 日
edges = 10.^(1:0.01:6);
[N,edges] = histcounts(x,edges,'Normalization','countdensity');
g = histogram('BinEdges',edges,'BinCounts',N);
set(gca, "Xscale", "log")
set(gca, "YScale", "log")
Allright, I'm going to answer my own question.
x is your data.
'countdensity' normalizes the data exactly how you want.
Make sure that the histogram command doesn't bin your data anymore,
as you have done it already in histcounts. :D

カテゴリ

Help Center および File ExchangeHistograms についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by