%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
% STS_distance %
% %
%%%%%%%%%%%%%%%%%%%%%%%%%%%
% To be called by sts_algorithm
function dist=m_distance(v,g,t)
n_t=size(g,2); %number of time points
n_g=size(g,1); %number of genes
n_c=size(v,1); %number of clusters
for c=1:n_c; % For all the prototypes
for j=1:n_g; % For all the genes
for k=1:n_t-1;
mv=(v(c,k+1)-v(c,k))/(t(k+1)-t(k)); % Slope of v
mg=(g(j,k+1)-g(j,k))/(t(k+1)-t(k)); % Slope of g
dd(k)=((mv-mg)^2); % Square of the difference of the slopes
end;
d=sum(dd); % Sum accross time points
dist(c,j)=d;
clear q dd;
end;
end;