clc
clear all
close all

X=xlsread('All Metrics.xlsx');
all_metrics=X(:,4:end);

for i=1:1:7
    a=min(all_metrics(:,i));
    b=max(all_metrics(:,i));
    am_normalized(:,i)=(all_metrics(:,i)-a)/(b-a);
end
all_metrics=am_normalized;

scopus_metrics=all_metrics(:,1:3);
JCR_metrics=all_metrics(:,5:7);
% all_metrics=[scopus_metrics,JCR_metrics];
% CV=cov(all_metrics);
% for i=1:1:6
%     S(i)=var(all_metrics(:,i));
% end
% for i=1:1:6
%     for j=1:1:6
%         CR(i,j)=CV(i,j)/(sqrt(S(i)*S(j)));
%     end
% end
% [E,D]=eig(CV);
% Data=all_metrics*E(:,end-1:end);
% [len,~]=size(Data);
% 
% for i=1:1:len
%     for j=1:1:len
%         Dist_mat(i,j)=dist(Data(i,:),Data(j,:)');
%     end
% end
% subplot(121)
% imagesc(CR)
% title('Covariance matrix of both Scopus and JCR metrics');
% subplot(122)
% imagesc(Dist_mat)
% title('Distance matrix of the considered journals with both scopus and JCR metrics')


%% Metrics for Scopus Database
CV1=cov(scopus_metrics);
for i=1:1:3
    S1(i)=var(scopus_metrics(:,i));
end
for i=1:1:3
    for j=1:1:3
        CR1(i,j)=CV1(i,j)/(sqrt(S1(i)*S1(j)));
    end
end
[E1,D1]=eig(CV1);
Data1=scopus_metrics*E1(:,2:3);
[len1,~]=size(Data1);

for i=1:1:len1
    for j=1:1:len1
        Dist_mat1(i,j)=dist(Data1(i,:),Data1(j,:)');
    end
end
DD1=[Data1(20,:);Data1(26,:)];
figure
subplot(121)
imagesc(CR1)
title('Covariance matrix of the Scopus metrics');
subplot(122)
imagesc(Dist_mat1)
title('Distance matrix of the considered journals with scopus metrics')


%% JCR Metrics for SCIE,SSCI Database
CV2=cov(JCR_metrics);
for i=1:1:3
    S2(i)=var(JCR_metrics(:,i));
end
for i=1:1:3
    for j=1:1:3
        CR2(i,j)=CV2(i,j)/(sqrt(S2(i)*S2(j)));
    end
end
[E2,D2]=eig(CV2);
Data2=JCR_metrics*E2(:,2:3);
[len2,~]=size(Data2);

for i=1:1:len2
    for j=1:1:len2
        Dist_mat2(i,j)=dist(Data2(i,:),Data2(j,:)');
    end
end
DD2=[Data2(20,:);Data2(26,:)];
figure
subplot(121)
imagesc(CR2)
title('Covariance matrix of the JCR metrics');
subplot(122)
imagesc(Dist_mat2)
title('Distance matrix of the considered journals with JCR metrics')
