How to know the equation of a curve fitted to histogram
40 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Abhiram B R
el 13 de En. de 2022
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 comentarios
Respuesta aceptada
Adam Danz
el 13 de En. de 2022
Editada: Adam Danz
el 13 de En. de 2022
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 comentarios
Más respuestas (0)
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!