Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.matlab

Topic: Fitting to a Gaussian using nlinfit
Replies: 5   Last Post: May 23, 2013 1:10 PM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Torsten

Posts: 1,472
Registered: 11/8/10
Re: Fitting to a Gaussian using nlinfit
Posted: Jan 10, 2013 10:37 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

"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.



Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.