How to know the equation of a curve fitted to histogram
16 ビュー (過去 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!