% ======================================================================
%> @brief Brief description of the corelation function
%>
%> This function compute correlation between results of subjective and 
%> objective measures.
%> \latexonly
%> \begin{equation}\label{corr}
%> \mathrm{\rho}=\frac{\sum_{d}(S_d-\bar{S}_d)(O_d-\bar{O}_d)}{\sqrt{\sum_{d}(S_d-\bar{S}_d)^2}\sqrt{\sum_{d}(O_d-\bar{O}_d)^2}},
%> \end{equation} 
%> \endlatexonly
%> @param Sd Contains results of subjective measure in a row vector.
%> @param Od Contains results of objective measure in a row vector.
%> @retval cor Returns correlation between Sd and Od.
% =====================================================================

function [ cor ] = corelation( Sd, Od )
%UNTITLED Summary of this function goes here
%   Detailed explanation goes here
%Sd= [24 10 4 16 6];
%Od= [0 0.0454 0.0132 0.0202 0.0123];
%Od= [24 10 4 16 6];
SSd=mean(Sd);
SOd=mean(Od);
for i=1:length(Sd);
a(i)=(Sd(i)-SSd)*(Od(i)-SOd);

b(i)=(Sd(i)-SSd)^2;
c(i)=(Od(i)-SOd)^2;
end
cor=sum(a)/(sqrt(sum(b))*sqrt(sum(c)));
fid = fopen('cor.txt', 'a+');
fseek(fid,0,'eof');
fprintf(fid, '%f ',cor);
fclose(fid);
end

