x  = [     0    1.2000    2.4000    3.6000    4.8000    6.0000];
y  = [5.1511    2.5335    0.1766   -2.0675   -4.4292   -7.1095];
sy = [0.2442    0.1050    0.1809    0.2716    0.2643    0.1667];



S   = sum(1 ./ sy.^2)
Sx  = sum(x ./ sy.^2)
Sy  = sum(y ./ sy.^2)
Sxx = sum(x.^2 ./ sy.^2)
Sxy = sum(x.*y ./ sy.^2)

delta = S*Sxx - Sx^2

n = (Sxx*Sy - Sx*Sxy) / delta
m = (S*Sxy - Sx*Sy) / delta

sn = sqrt(Sxx / delta)
sm = sqrt(S / delta)

set(0,'defaultaxesfontsize', 18);



errorbar(x,y,sy,'o')

xx = -1:0.01:7;
yy = n + m*xx;
hold on
plot(xx, yy, 'r-')
hold off

axis([-1 7 -8 6])

xlabel('Time (sec)')
ylabel('\lambda (m)')

print -depsc sample_plot.eps
