# 熵權法原理及適用情況

m1:一張表格裡面有若干個指標
m2:一張表格裡面有若干個指標
m3:一張表格裡面有若干個指標
m4:一張表格裡面有若干個指標
m5:一張表格裡面有若干個指標
m6:一張表格裡面有若干個指標

clc;clear
[z1,g1] = size(m2);
[z2,g2] = size(m3);
[z3,g3] = size(m5);
[z4,g4] = size(m1);
[z5,g5] = size(m6);
[z6,g6] = size(m4);
mm=[m2,m3,m5,m1,m6,m4];
for ii=1:6
if ii ==1
g=g1;
x2=mm(:,1:g);
elseif ii==2
g=g1 g2;
g0=g1 1;
x2=mm(:,g0:g);
elseif ii==3
g0=g1 g2 1;
g=g1 g2 g3;
x2=mm(:,g0:g);
elseif ii==4
g0=g1 g2 1 g3;
g=g1 g2 g3 g4;
x2=mm(:,g0:g);
elseif ii==5
g0=g1 g2 1 g3 g4;
g=g1 g2 g3 g4 g5;
x2=mm(:,g0:g);
else
g0=g1 g2 1 g3 g4 g5;
g=g1 g2 g3 g4 g5 g6;
x2=mm(:,g0:g);
end
N2 = ( max(x2(:))-x2)/(max(x2(:))-min(x2(:)));% 全部定義為負指標
x1=N2;
y=[];
f=[];
[m,n]=size(x1);
for i=1:n
y(:,i)=x1(:,i)/sum([x1(:,i)])   ;    % 矩陣標準化
end
for l=1:n
s(1,l)=0;
for j=1:m
if y(j,l)==0;%%%%%%%%“==”表示等於“=”是賦值
p(1,l)=0;
s(1,l)=s(1,l);
else
p(1,l)=y(j,l)*log(y(j,l));
s(1,l)=s(1,l) p(1,l);
end
end
end
k=(log(m))^(-1);
e=-k*s;
h=ones(1,n)-e;
w=h/sum(h)          % 指標權重值
if ii==1
m22= m2*w';
elseif ii==2
m33 =m3*w';
elseif ii==3
m55=m5*w';
elseif ii==4
m11 = m1*w';
elseif ii==5
m66=m6*w';
else
m44= m4*w';
end
end
mz=[m11,m22,m33,m44,m55,m66];  %m1到m6的綜合評價值