% FILE d016hlp.m begins.
% MME08 harj 1 teht 6
close all
n =30;   %Fix n
x= (1:n)*0.1;
myerror=(rand(1,n)-0.5)*0.5;
ssxx= sum((x-mean(x)).^2);
myval=[];
for tst=1: 10     % counter for test number
c=0.5+0.05*tst;
y= 0.7*x+ c*myerror;
ssyy= sum((y-mean(y)).^2);
ssxy= sum((x-mean(x)).*(y-mean(y)));
r= ssxy/sqrt(ssxx*ssyy);
fprintf('%2d. test, c= %5.3f , r= %6.4f\n',tst, c, r)
     myval=[myval; [c r]];
end              % end of tst loop
figure
axes('FontSize',[18],'FontWeight','bold');
hold on
plot(myval(:,1), myval(:,2),'k-','LineWidth',2)
grid on
title('teht. 1.6','FontSize', 18,'FontWeight','bold');
xlabel('c')
ylabel('r')
% FILE d016hlp.m ends.
