Histfit : how to set minimum and maximum value for clusters?

10 ビュー (過去 30 日間)
Ivan Mich
Ivan Mich 2021 年 2 月 15 日
コメント済み: Ivan Mich 2021 年 2 月 17 日
Hello,
I want to create a histogram. I want my histogram to start from a specific minimum value and to end to a specific maximum value. I would like to set this values by default let's say. How to make it?
I use the following commands:
H=histfit(x,10,'normal'); %creates 10 clusters, I want my clusters to start from xmin=1, and end to xmax=10, by 0.5 step
x=d1.data(:,4); %x is my data
could you help me?

回答 (1 件)

KALYAN ACHARJYA
KALYAN ACHARJYA 2021 年 2 月 16 日
Is this?
Get the minimum and maximum value from the x data, considering x as a 1D array
x_min=min(x);
x_max=max(x);
Next you can modify the x data as per x_min and x_max, the remaining x data without minimum x and maximum x
x(x==x_min | x==x_max)=[]
Next plot the hist
H=histfit(x,10,'normal');
  1 件のコメント
Ivan Mich
Ivan Mich 2021 年 2 月 17 日
look, I want to fit a histogram to some data using predefined bins. All my data points are between 1 and 10, so I want the bins to start from xmin=1, and end at xmax=10, with a step of 0.5.
I use the following commands:
x = d1.data(:,4); % x is my data
H = histfit(x,10,'normal'); % fits a histogram using 10 bins
However when doing the above, bins are determined automatically per dataset and do not correspond to the edges I want. How can I ensure that the same bin edges are used for all datasets?

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

カテゴリ

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