The Math Forum

Search All of the Math Forum:

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

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

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

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 ]

Posts: 1,717
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$>...
> "Torsten" wrote in message <kcmih3$o3$>...

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

Best wishes

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

[Privacy Policy] [Terms of Use]

© The Math Forum at NCTM 1994-2018. All Rights Reserved.