function [Error,error1,error2,index] = disclass(R,y,mean1,mean2)
%% assign the class label of a sample
% Input     
%      R: the matrix of the data 
%      y: the class of the data
%      meanR1 and meanR2: the mean value of each class
% Output     
%      Error:  the total number of misclassification 
%      error1 and error2: the number of misclassification in each class
%      index: the index of misclassification 


n = find(diff(y)~=0); 
temp = []; 

temp(1,:) = fastdist(R,mean1);  
temp(2,:) = fastdist(R,mean2); 
[g,index] = min(temp);
m1= find(index(1:n)>1);
error1=length(m1);
m2= find(index(n+1:end)<2)+n; 
error2=length(m2);
Error =sum(error1+error2);
