clear all;
%ex. 3, 4
close all;

fid=fopen("file_03_11a.txt","r");
Y=[];
s=fgets(fid);
while(s!=(-1))
Y=[Y,str2num(s)];
s=fgets(fid);
end
fclose(fid);

fid=fopen("file_03_11b.txt","r");
W=[];
s=fgets(fid);
while(s!=(-1))
W=[W,str2num(s)];
s=fgets(fid);
end
fclose(fid);

X=[];Z=[];U=[];
n=length(Y);
for i=1:n/2
  X(i)=Y(2*i-1);
  U(i)=W(2*i-1);
  Z(i)=Y(2*i);
end
rc=corrcoef(X,Z);
r=rc(2,1);
hx=figure();



scatter (X,Z, 225, 'b','.');
xlabel("the first test scores","FontSize",16);
ylabel("the final exam scores","FontSize",16,'rotation',90);
title ("Final exam versus the first test","FontSize",16);

figure();

scatter (U,Z, 225, 'r','.');
xlabel("the second test scores","FontSize",16);
ylabel("the final exam scores","FontSize",16,'rotation',90);
title ("Final exam versus the second test","FontSize",16);
G=[ones(1,8),ones(1,8)+1];
XX=[X,U]; ZZ=[Z,Z];

figure();
gscatter(XX,ZZ,G,'br','..',[16,16]);
xlabel("the first and second test scores","FontSize",16);
ylabel("the final exam scores","FontSize",16,'rotation',90);
title ("Final exam versus the first and second test","FontSize",16);

