How to know the equation of a curve fitted to histogram
    11 visualizzazioni (ultimi 30 giorni)
  
       Mostra commenti meno recenti
    
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 Commenti
Risposta accettata
  Adam Danz
    
      
 il 13 Gen 2022
        
      Modificato: Adam Danz
    
      
 il 13 Gen 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 Commenti
Più risposte (0)
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


