function[correlation,ratio] = maxcorr11(dollar5,dollar10,dollar20,dollar50,dollar100,d,input);
% This program is used to calculate the correlation between then input and
% the respective templates. The templates are passed into the function is
% dollar5, dollar10, dollar20, dollar50 and dollar100. The input in this
% case can be a matrix with any number of rows but has to be 512 columns.
% d is the normalising factor that will be used to calculate the ratio for
% each note.
% 

[row col] = size(input);

% Calculating the correlation value for all the inputs compared to the
% templates
for i = 1:row
    output(i)  = corr(dollar5,input(i,:));
    output1(i) = corr(dollar10,input(i,:));
    output2(i) = corr(dollar20,input(i,:));
    output3(i) = corr(dollar50,input(i,:));
    output4(i) = corr(dollar100,input(i,:));
end


% Obtaining the mean of the inputs to get a better correlation value
output = mean(output);
output1 = mean(output1); 
output2 = mean(output2);
output3 = mean(output3);
output4 = mean(output4);


% Calculating the ratio 
correlation = [output output1 output2 output3 output4];
ratio = (correlation./d)*100;

