; File: fit_y.pro
; Author: Erik Brisson


N = 10
y = fltarr(N)

openr, 1, 'dat/ex_y.dat'
readf, 1, y
close, 1
print, 'print y'
print, y
print, 'another way to print y'
for i=0, N-1 do begin
    print, y(i)
endfor

plot, psym=1, y

x = findgen(N)
ypoly = poly_fit(x, y, 3)
print, 'coefficients of third degree fit'
print, ypoly

yapprox = ypoly(0) + ypoly(1)*x + ypoly(2)*x^2 + ypoly(3)*x^3
print, 'values of fit at corresponding x values'
print, yapprox
oplot, yapprox

end
