help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Gaussian fit of a peak


From: Julius Smith
Subject: Re: Gaussian fit of a peak
Date: Tue, 23 Sep 2008 16:59:22 -0600

For the single-Gaussian case, you can take a log and fit a parabola:

x = -1:0.1:1;
sigma = 0.01;
y = exp(-x.*x) + sigma*randn(size(x));
[p,s] = polyfit(x,log(y),2);
yh = exp(polyval(p,x));
norm(y-yh)    % ans =  1.9230e-16 when sigma=0
plot([y',yh']);

- Julius

On Wed, Sep 17, 2008 at 8:20 AM, Andrea Cimatoribus <address@hidden> wrote:
> Hi everybody,
> I am an absolute novice of octave, even though I have some experience
> with matlab.
> Just to get the feeling of octave, I am presently translating a simple
> (but very useful to me) script, that basically sums data with a peak
> structure. In order to do this properly, I need to centre each new
> spectrum on the zero, that is the peak maximum. My strategy, in
> matlab, was to make a preliminary gaussian fit, whose result was to be
> confirmed through a graphical input, to get the "zero" of the
> spectrum. As of now, I am trying to understand how can I make a
> gaussian fit of the data in octave. Data is simply organised as a
> matrix [x,y]. Is there a built function? Sorry but I can't find
> anything with online help.
> Andrea
> _______________________________________________
> Help-octave mailing list
> address@hidden
> https://www-old.cae.wisc.edu/mailman/listinfo/help-octave
>
>



-- 
"Anybody who knows all about nothing knows everything" -- Leonard Susskind


reply via email to

[Prev in Thread] Current Thread [Next in Thread]