How can I bin a set of data probability and plot it as a bar chart ?

39 ビュー (過去 30 日間)
Gabs
Gabs 2015 年 9 月 16 日
コメント済み: Gabs 2015 年 9 月 16 日
I have a set of observed data of 3 years of hourly measurements "x" (25920x1 double) with min = 0.00003484 and max = 3.8787 ;
I want to plot a figure that has the following characteristics:
1. x axis = x values, y axis = probability density
2. X should be binned for one month and plotted as a bar chart (look like a bar chart)
3. A normal pdf (based on the mean and std of the observed data) must be plotted
This is in order to compare the existing data and a normal dist or how well the fit in the graph.
I don't even know how to start, how can I do this? Any idea? I am having trouble binning the data and plotting it as a bar chart of the pdf. The normal pdf plotting is not an issue

採用された回答

the cyclist
the cyclist 2015 年 9 月 16 日
If you have the Statistic and Machine Learning Toolbox, you could use the histfit command.

その他の回答 (1 件)

Image Analyst
Image Analyst 2015 年 9 月 16 日
Decide how many bins you want and then call histcounts. For example (untested)
x = 4*randn(1, 10000);
numBins = 30;
[counts, edges] = histcounts(x, numBins);
binWidth = edges(2)-edges(1);
binCenters = edges(1:end-1) + binWidth/2;
bar(binCenters, counts, 'BarWidth', 1, 'FaceColor', 'b');
grid on;
To get the PDF, divide counts by the total number of counts. Then do the other stuff - if you still have trouble then write back.
  1 件のコメント
Gabs
Gabs 2015 年 9 月 16 日
I have an older version which does not have the histcounts function

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

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by