How to get more precise cdf pdf plot?
4 views (last 30 days)
Show older comments
Chen Zhu
on 5 Nov 2017
Answered: Kaushik Lakshminarasimhan
on 5 Nov 2017
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
0 Comments
Accepted Answer
Kaushik Lakshminarasimhan
on 5 Nov 2017
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 Comments
More Answers (0)
See Also
Categories
Find more on Histograms in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!