Fit Polynomial
13: Fitting a function to x-y data points
Read in some x-y data and then find a least-squares fit to the data as a linear combination of given functions, or as a nonlinear function.
| 1. Read in arrays x and y from file xyL.dat, and find the best 5th-degree polynomial fit
2. Read in arrays x and y from file xyN.dat, and find the best fit to y(x) = a exp(bx) sin(cx + d) |
| Mathematica:
(1)
|
Matlab:
(1) (2) |
| Maple:
xxx |
IDL:
(1) xy = fltarr(2,21)
PRO YofX, x, A, f x=reform(xy[0,*]) & y=reform(xy[1,*]) |
