How can I bin a set of data probability and plot it as a bar chart ?
38 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
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
0 Commenti
Risposta accettata
Più risposte (1)
Image Analyst
il 16 Set 2015
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.
Vedere anche
Categorie
Scopri di più su Bar Plots in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!