|
|
Re: surface fit [message #3150 is a reply to message #3059] |
Wed, 09 November 1994 05:53  |
thompson
Messages: 584 Registered: August 1991
|
Senior Member |
|
|
buteau@bali.saclay.cea.fr (A.Buteau 62 17) writes:
> I don't understand what you mean by :
>> One then is not fitting F(X,Y) but F(S). All one needs to do then is to
>> write the definition of the function so that it can then determine X(S) and
>> Y(S). A simple way to do this is through a common block.
O.K., here's a simple example. Suppose that one wanted to fit a
two-dimensional gaussian to a set of X-Y points, i.e.
F(X,Y) = A0 + A1*exp(-r^2/(2*sigma^2))
r^2 = (x-X0)^2 + (y-y0)^2
One would then write the function as follows:
FUNCTION GAUSS2, S, A, PDER
COMMON GAUSS2_COM, X_ARRAY, Y_ARRAY
X = X_ARRAY(S)
Y = Y_ARRAY(S)
R2 = (X - A(2))^2 + (Y - A(3))^2
F = A(0) + A1*EXP(-R2/(2.*A(4)^2))
PDER = ... ;Left as an exercise to the reader :^)
RETURN, F
END
Your actual measurement points are a series of X,Y pairs. These are stored as
X_ARRAY, Y_ARRAY in the GAUSS2_COM common block. S is simply an index array
running from 0 to one less than the number of points. If the measured values
at these points are Z, then one can call CURVEFIT as follows
Result = CURVEFIT(S, Z, W, A, SIGMAA, FUNCTION='GAUSS2')
Bill Thompson
|
|
|