function hw3
s1=load('~/CS612/homework/set1.txt');
s2=load('~/CS612/homework/set2.txt');
r=rmsd(s1,s2) % part a
cen1 = mean(s1,1);
cen2 = mean(s2,1);
% repmat creates a matrix with copies of the vector for line-by-line
% subtraction
r=rmsd(s1-repmat(cen1,size(s1,1),1),s2-repmat(cen2,size(s2,1),1))
end

function [r] = rmsd(X, Y)
szx=size(X,1);
szy=size(Y,1);
if(szx ~= szy)
    error('Vectors not the same size')
end
r=(X-Y).^2; % Square distance
r=(sum(sum(r))); % Sum the distances
r=r/szx; % Mean
r=sqrt(r); % Square root
end

