% This function does an octave by octave comparison by dot
% product.  It normalizes each octave, dots, and then returns
% the sum of the results

function diff = normdiff(vec1, vec2);

a1 = sum(dotnorm(vec1(1,4097:8192)).*dotnorm(vec2(1,4097:8192)));
a2 = sum(dotnorm(vec1(1,2049:4096)).*dotnorm(vec2(1,2049:4096)));
a3 = sum(dotnorm(vec1(1,1025:2048)).*dotnorm(vec2(1,1025:2048)));
a4 = sum(dotnorm(vec1(1,513:1024)).*dotnorm(vec2(1,513:1024)));
a5 = sum(dotnorm(vec1(1,257:512)).*dotnorm(vec2(1,257:512)));
a6 = sum(dotnorm(vec1(1,129:256)).*dotnorm(vec2(1,129:256)));
a7 = sum(dotnorm(vec1(1,65:128)).*dotnorm(vec2(1,65:128)));
a8 = sum(dotnorm(vec1(1,1:64)).*dotnorm(vec2(1,1:64)));

diff = (a1) + (a2) + (a3) + (a4) + (a5);



