I am generating random numbers. The histogram has a sample size of 20 but only 5 bars. How can I control the bar numbers?

 採用された回答

Sindar
Sindar 2020 年 10 月 25 日

1 投票

histogram accepts the number of bins as a second argument:
x = randn(1000,1);
nbins = 25;
h = histogram(x,nbins)

1 件のコメント

Mustafa Vural
Mustafa Vural 2020 年 10 月 25 日
thank you very much!

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

その他の回答 (1 件)

drummer
drummer 2020 年 10 月 25 日

1 投票

This doc for histogram has the info to play with the number of bins in your histogram
If you're using such command, you can do it by histogram(X, nBinsYouWant)

1 件のコメント

Mustafa Vural
Mustafa Vural 2020 年 10 月 25 日
thank you for the advice!

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

カテゴリ

タグ

質問済み:

2020 年 10 月 25 日

コメント済み:

2020 年 10 月 25 日

Community Treasure Hunt

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

Start Hunting!

Translated by