Fitting gaussian curve to histogram in MATLAB
Fitting gaussian curve to histogram in MATLAB
I have a data set in excel so I passed it to MATLAB to draw a histogram and append gaussian fitting. My code is below.
vData = xlsread("2.xlsx");
figure(1);
hHist = histogram(vData, -2.7:0.001:-2.4);
As I run my code, I get a histogram like this
histogram of my data
To gaussian fit my histogram, I add some code like this
figure(2);
histfit(vData); % I'm not sure this is the right fitting method
But the result I got is like this
fitting on histogram
I guess the bin size and bin edge is not appropriate for my data because my data is usually clustered around -2.5.
hisfit method doesn't have bin size or bin edge parameter so I think I can't use this method.
I'm wondering how I can get an appropriate gaussian fitting to my histogram. Thank you for you help.
max(vData)
It worked. Thanks for your help!
– JaeWon Kim
Sep 7 '18 at 4:15
0
Thanks for contributing an answer to Stack Overflow!
But avoid …
To learn more, see our tips on writing great answers.
Required, but never shown
Required, but never shown
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
Do you have an extreme outlier in your data? What is
max(vData)
? If yes, removing the outlier(s) would solve your issue.– Cris Luengo
Sep 7 '18 at 2:07