Creating a histogram with specified data

4 ビュー (過去 30 日間)
Eric Tang
Eric Tang 2020 年 6 月 21 日
コメント済み: Eric Tang 2020 年 6 月 21 日
I tried making a histogram with following criterion.
x = 2.5*randn(1,100000)-1.7
hist(x,[-6:0.25:4])
The middle part of the histogram looks fine to me. But there's two werid solid blocks at the beginning and end. Does anyone know how to fix it? Here's the photo for your reference. Thank you.

採用された回答

KALYAN ACHARJYA
KALYAN ACHARJYA 2020 年 6 月 21 日
編集済み: KALYAN ACHARJYA 2020 年 6 月 21 日
If you want two remove those extra blank space, you can use xlim (Limitinng x axis scale).
x = 2.5*rand(1,200)-1.7
hist(x,[-6:0.25:4])
xlim([-2 1])
Please note technically you have to keep all scale ranges, as hostogram shows the repetions in different ranges (all possible scale ranges, any particular value is not thres, then it shows 0 level).
If you looking for different issue, then let me know detail?
  3 件のコメント
KALYAN ACHARJYA
KALYAN ACHARJYA 2020 年 6 月 21 日
編集済み: KALYAN ACHARJYA 2020 年 6 月 21 日
x = 2.5*randn(1,100000)-1.7
data1=-6:0.25:4;
hist(x,data1)
xlim([-5.8,3.8]);
Here I have just limiting the scale range. Please note you use to hist of 1 D array to plot the hist (x and data1=[-6:0.25:4];)
or
remove those data in the vector itselt
x = 2.5*randn(1,100000)-1.7
data1=-6:0.25:4;
hist(x(-5.8<x & x<3.8),data1(-5.8<data1<3.8))
Eric Tang
Eric Tang 2020 年 6 月 21 日
Thank you!

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

その他の回答 (0 件)

カテゴリ

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

タグ

製品


リリース

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by