How to know the equation of a curve fitted to histogram
39 次查看(过去 30 天)
显示 更早的评论
Hi matlab users,
I have plotted a histogram in matlab and then used
histfit(pair_dist,9,'kernel')
command to fit a curve to the histogram. Now i need to find the equation of curve fitted with this histogram. Can anyone suggest a way to find out this?
0 个评论
采纳的回答
Adam Danz
2022-1-13
编辑:Adam Danz
2022-1-13
The output of histfit is a vector of handles, one of which is a line object containing the x/y values for the curve. You could fit those line values to a gaussian function to get the fit parameters. Update: if you're using "kernel", that's a nonparametric kernel-smoothing distribution where the density is evaluated at 100 equally spaced points that cover the range of the data so it has no parameters to fit.
Alternatively, you could use fitdist instead of histfit to fit the distribution and return the fit parameters. These two methods are compared in this answer.
y = randn(1,1000)+6.2*9.8;
h = histfit(y);
lineobj = findobj(h,'type','line');
gx = lineobj.XData;
gy = lineobj.YData;
f = fit(lineobj.XData',lineobj.YData','gauss1')
% Now plot the fitted line again see that it's the same
hold on
plot(f,'g-')
0 个评论
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!