% Test least square straight line fit and correlation coefficient with
% TestLScorrcoeff.m
% random x-y data.  L Braile 9/04
nruns = 20;
npts = 20;
for i = 1:nruns
n = npts;
x = rand(1,n);
y = rand(1,n);
mode = 0;
sigmay = ones(1,n);
[a,sigmaa,b,sigmab,r]=linfit(x,y,sigmay,n,mode);
figure, plot(x,y,'or'), hold on
z = feval('sline',x,a,b);
xlabel('x value')
ylabel('y value')
title('LSQ line and Corr. Coeff. for 20 Random x-y points')
rtext = num2str(r);
text(0.03,0.05,'r =')
text(0.08,0.05,rtext)
plot(x,z,'k-')
axis([0 1 0 1]);
hold
[i a sigmaa b sigmab r]
end