How to get more precise cdf pdf plot?

4 次查看(过去 30 天)
sample1=[...];
sample2=[...];
[p,x] = hist(sample1);
[p2,x2] = hist(sample2);
plot(x,p/sum(p),'r'); %PDF
hold on
plot(x2,p2/sum(p2),'g'); %PDF
I used code above to plot CDF and PDF. However, the plot is not very precise. I want to get more smooth plot. How can I make the distance between each point be 10? Currently, it seems like 100.
Thanks

采纳的回答

Kaushik Lakshminarasimhan
By default hist uses 10 bins to create a histogram. You can change the resolution either by specifying the number of bins or the bin centres. For example, to make a histogram with 100 bins:
[p,x] = hist(sample1,100);
Alternatively, you can specify the bin centres instead of number of bins.
bincntr = 10:10:2000
[p,x] = hist(sample1,bincntr);
In the second case, x will be equal to bincntr

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Histograms 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by