How to get more precise cdf pdf plot?
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Chen Zhu
am 5 Nov. 2017
Beantwortet: Kaushik Lakshminarasimhan
am 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.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/169195/image.jpeg)
Thanks
0 Kommentare
Akzeptierte Antwort
Kaushik Lakshminarasimhan
am 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 Kommentare
Weitere Antworten (0)
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!