MATLAB Answers

Weird fitting result from using 'ksdensity'

16 views (last 30 days)
Yiran Chang
Yiran Chang on 10 Feb 2021
Commented: Yiran Chang on 12 Feb 2021
I have a histogram of frequency distribution (pic 1), theoretical there could be more than one peak, so I used ksdensity for fitting. But I got a reallly weird fitting.(pic 2)
code I used:
figure
x = [Tracks.norm_amp];
histogram(x,'Normalization','probability')
[f,xi] = ksdensity(x,'kernel','normal','support','positive');
hold on
plot(xi,f)
It wil be great if someone can help me! Thanks a lot!

Accepted Answer

Jeff Miller
Jeff Miller on 11 Feb 2021
Try
histogram(x,'Normalization','pdf')
  1 Comment
Yiran Chang
Yiran Chang on 12 Feb 2021
Worked! I really appreciate your help!

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!