[go: up one dir, main page]

Menu

[r377]: / idl_lib / n_interpolate.pro  Maximize  Restore  History

Download this file

22 lines (17 with data), 472 Bytes

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
;returns the coefficients of a polynomial fitted to the
;curve defined by x and y
;the order of the polynomial is the number of points in x and y
function n_interpolate, x, y
x=reform(x)
y=reform(y)
npts=min([n_elements(x), n_elements(y)])
;define the matrix to be solved:
matrix=fltarr(npts, npts)
for i=0, npts-1 do begin
matrix[i, *]=x^i
endfor
;solve the matrix:
ludc, matrix, index
; print, npts
return, lusol(matrix, index, y)
end