%
% Script file: P4dataY.m - plotY.m
% A Quadratic Least Squares Fit for DataY
%
fin=fopen('dataY.txt','r');
fgetL(fin);
m=2;  n=13;
T=fscanf(fin,'%f',[m n]);
fclose(fin);
T=T';
X=T(:,1);
Y=T(:,2);
[P S]=polyfit(X,Y,2);
ymu=mean(Y);
Yh=P(1)*X.^2 + P(2)*X + P(3); 
top=norm(Yh-ymu,2);
bot=norm(Y-ymu,2);
R2=(top*top)/(bot*bot);
P,R2
plot(X,Y,'ro',X,Yh,'b-');
legend('R^2 Statistics=0.9812','\itY=-0.1737\itX^2+14.5212\itX-21.8977',4);
title('Quadratic Curve Fitting for dataY')