%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
fea_Train = fea(:,trainIdx);
gnd_Train = gnd(trainIdx);
fea_Test = fea(:,testIdx);
gnd_Test = gnd(testIdx);
train_size = length(gnd_Train);
test_size = length(gnd_Test);
%%%%%%%%%%%%%%%%%%%%%%%Normalization begins%%%%%%%%%%%%%%%%%%%%%%%
train_data_std = std(fea_Train');
train_data_mean = mean(fea_Train');
train_data_std_matrix = ones(train_size,dim)*diag(train_data_std);
train_data_std_matrix(train_data_std_matrix==0)=1;
train_data_mean_matrix = ones(train_size,dim)*diag(train_data_mean);
train_scale_data = (fea_Train' - train_data_mean_matrix)./train_data_std_matrix;
clear train_data_mean_matrix train_data_std_matrix;
fea_Train = train_scale_data';
clear train_scale_data;
test_data_std_matrix = ones(test_size,dim)*diag(train_data_std);
test_data_mean_matrix = ones(test_size,dim)*diag(train_data_mean);
clear train_data_mean train_data_std;
test_data = (fea_Test' - test_data_mean_matrix)./test_data_std_matrix;
clear test_data_std_matrix test_data_mean_matrix;
fea_Test = test_data';
clear test_data;
%%%%%%%%%%%%%%%%%%%%%%%Normalization ends%%%%%%%%%%%%%%%%%%%%%%%