Search All of the Math Forum:
Views expressed in these public forums are not endorsed by
Drexel University or The Math Forum.
|
|
Torsten
Posts:
1,182
Registered:
11/8/10
|
|
Re: Fitting to a Gaussian using nlinfit
Posted:
Jan 10, 2013 10:37 AM
|
|
"Ben" wrote in message <kcmjis$4us$1@newscl01ah.mathworks.com>... > "Torsten" wrote in message <kcmih3$o3$1@newscl01ah.mathworks.com>... > > > You fit the log of your data against the log of your fit function. > > This introduces a distortion to the estimates of your parameters. > > Why don't you try the direct way > > [bestfit,resid]=nlinfit(dp_data,N_data,norm_func,init_guesses); > > ? > > > > Best wishes > > Torsten. > > The reason why I used the log of my function is because of the reasons stated in the tutorial I linked to above (mainly that my function is not allowed negative values). I tried your suggestion, however, and the fit does look better but I'm still getting the same error message. Is there a way to restrict the allowed values for the parameters of nonlinfit? If anyone has any better suggestions for fitting a gaussian curve to this type of data, please let me know. I've been struggling with this for a while now.
Scale your N_data and your fit function by a common factor (e.g. 1e10). Then the error message should disappear.
I obtain quite a good fit for p(1)=1.95311e12 p(2)=2.85163e-8 p(3)=7.16019e-9
Best wishes Torsten.
|
|
|
|