Home > Scripts > Models > gauss2d.m

iFit/gauss2d

PURPOSE ^

signal = gauss2d(p, x, y, {signal}) : 2D Gaussian function

SYNOPSIS ^

function signal=gauss2d(varargin)

DESCRIPTION ^

 signal = gauss2d(p, x, y, {signal}) : 2D Gaussian function

   iFunc/gauss2d 2D Gaussian function (fit 2D function/model)
     x0=p(2); y0=p(3); sx=p(4); sy=p(5); theta=p(6) [given in deg]
     a = cos(theta)^2/2/sx/sx + sin(theta)^2/2/sy/sy;
     b =-sin(2*theta)/4/sx/sx + sin(2*theta)/4/sy/sy;
     c = sin(theta)^2/2/sx/sx + cos(theta)^2/2/sy/sy;
     signal = p(1)*exp(-(a*(x-x0).^2+2*b*(x-x0).*(y-y0)+c*(y-y0).^2)) + p(7);

   The HalfWidth parameters are the Gaussian square root variances (Sigma). 
   The 'true' half widths are thus 1.177*HalfWidth.

 gauss2d([w1 w2])        creates a model with a specified widths
 gauss2d([ parameters ]) creates a model with specified model parameters

 Reference: http://en.wikipedia.org/wiki/Gaussian_function

 input:  p: gauss2d model parameters (double)
            p = [  'Amplitude' 'Centre_X' 'Center_Y'
                   'HalfWidth_X' 'HalfWidth_Y' 'Angle' 'Background' ] 
            the rotation angle is given in degrees.
          or 'guess'
         x: axis along rows    (double)
         y: axis along columns (double)
    signal: when values are given, a guess of the parameters is performed (double)
 output: signal: model value
 ex:     signal=gauss2d([1 2 .5 .2 .3 30 .2], -2:.1:2, -3:.1:3); or plot(gauss2d)

 Version: Aug. 22, 2017
 See also iData, iFunc/fits, iFunc/plot, gauss
 (c) E.Farhi, ILL. License: EUPL.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:
Generated on Tue 22-Aug-2017 11:03:30 by m2html © 2005. iFit (c) E.Farhi/ILL EUPL 1.1