SFIT function determines a polynomial fit to a
surface and returns a fitted array. The function fitted is:
This routine is written in the IDL language. Its source code can be found in the file
subdirectory of the IDL distribution.
Result = SFIT(
The two-dimensional array of data to fit. The sizes of the dimensions may be unequal.
The maximum degree of fit (in one dimension).
Set this keyword to a named variable that will contain the array of coefficients for a polynomial function of
to fit data. This parameter is returned as a
Create a grid from zero to six radians in the X and Y directions:
X = (FINDGEN(61)/10) # REPLICATE(1,61)
Y = TRANSPOSE(X)
Evaluate a function at each point:
F = -SIN(2*X) + COS(Y/2)
Compute a sixth-degree polynomial fit to the function data:
result = SFIT(F, 6)
Display the original function on the left and the fitted function on the right, using
identical axis scaling:
WINDOW, XSIZE = 800, YSIZE = 400
!P.MULTI = [0, 2, 1]
!P.BACKGROUND = 255
!P.COLOR = 0
SURFACE, F, X, Y, ZRANGE = [-3, 3], ZSTYLE = 1
SURFACE, result, X, Y