clear,clg,orient landscape
snam = input('Enter site name ','s');

eval(['load ' snam '_NEU'])
eval(['t = ' snam '_NEU(:,1);'])
eval(['n = ' snam '_NEU(:,2)*1000;'])
eval(['e = ' snam '_NEU(:,3)*1000;'])
eval(['u = ' snam '_NEU(:,4)*1000;'])
eval(['dn = ' snam '_NEU(:,5)*1000;'])
eval(['de = ' snam '_NEU(:,6)*1000;'])
eval(['du = ' snam '_NEU(:,7)*1000;'])

subplot(3,1,1),errorbar(t,n,dn)
subplot(3,1,2),errorbar(t,e,de)
subplot(3,1,3),errorbar(t,u,du)
zoom on

Cn = zeros(length(t),length(t));
Ce = zeros(length(t),length(t));
Cu = zeros(length(t),length(t));

for j = 1:length(t);
Cn(j,j) = dn(j)^2;
Ce(j,j) = de(j)^2;
Cu(j,j) = du(j)^2;
end

A = [ones(length(t),1) t];

%y = inv(A' * inv(Cn) * A) * A' * inv(Cn) * n
%subplot(3,1,1), hold on
%plot(t,A*y,'g-')

%y = inv(A' * inv(Ce) * A) * A' * inv(Ce) * e
%subplot(3,1,2), hold on
%plot(t,A*y,'g-')

%y = inv(A' * inv(Cu) * A) * A' * inv(Cu) * u
%subplot(3,1,3), hold on
%plot(t,A*y,'g-')

