The 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 sfit.pro in the lib subdirectory of the IDL distribution.
Result = SFIT( Data, Degree [, KX=variable] )
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 x and y to fit data. This parameter is returned as a Degree+1 by Degree+1 array.
; 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 ; Set up side-by-side plots:!P.MULTI = [0, 2, 1] ; Set background color to white:!P.BACKGROUND = 255 ; Set plot color to black:!P.COLOR = 0 SURFACE, F, X, Y, ZRANGE = [-3, 3], ZSTYLE = 1 SURFACE, result, X, Y
The following figure shows the result of this example. The original function is on the left and the fitted function is on the right:
Introduced: Pre 4.0
CURVEFIT, GAUSSFIT, LINFIT, LMFIT, POLY_FIT, REGRESS, SVDFIT