How to set the Bin width of the histogram ?

280 ビュー (過去 30 日間)
karanvir sidhu
karanvir sidhu 2019 年 6 月 13 日
回答済み: Paramjit Yadav 2021 年 7 月 8 日
I am setting the bin width to 0.05 as can be in seen in the code snipet below
h1 = histogram(Data);
h1.Normalization = 'probability';
h1.BinWidth = 0.05;
But the histogram does not set the bin width to 0.05. It varies every time I run the function.
Please help.
  1 件のコメント
the cyclist
the cyclist 2019 年 6 月 13 日
This code set the bin width to 0.05 for me, as expected.
Data = rand(100,1);
h1 = histogram(Data);
h1.Normalization = 'probability';
h1.BinWidth = 0.05;
Can you upload an example of the variable Data that exhibits the problem?

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

回答 (2 件)

Paramjit Yadav
Paramjit Yadav 2021 年 7 月 8 日
How to set the bin width and bin edges simulataneously. Please help.
  2 件のコメント
the cyclist
the cyclist 2021 年 7 月 8 日
編集済み: the cyclist 2021 年 7 月 8 日
If you define the edges, then the widths are determined by the differences between the edges. I don't see how your question makes sense.
Also, you might want to ask a new question. The way you entered this, it is appearing as an "answer" to another question.
Steven Lord
Steven Lord 2021 年 7 月 8 日
If you're explicitly setting the bin edges, that fixes the bin widths (potentially to non-uniform values.) So just set the edges.

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


Paramjit Yadav
Paramjit Yadav 2021 年 7 月 8 日
Thank you so much.

カテゴリ

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