『壹』 求熵值法計算權重的matlab代碼,並且舉個例子算一下,發送到[email protected],謝謝!
x=[1 2 3 56 7
2 3 5 45 8
1 2 4 56 8
];
[n,m]=size(x);
k=1/log(n);
X=zeros(n,m);
for j=1:m
for i=1:n
c=sort(x(:,j));
big=x(n,j);
small=x(1,j);
X(i,j)=(x(i,j)-small)/(big-small)+1;
end
end
p=[];
for j=1:m
th=0;
for t=(X(:,1))'
th=th+t;
end
Ph=X(:,j)/th;
p=[p Ph];
end
e=[];
for j=1:m
eg=0;
for i=1:n
eh=-k*p(i,j)*log(p(i,j));
eg=eg+eh;
end
e=[e,eg];
end
E=0;
for j=1:m
E=E+e(j);
end
g=[];
for j=1:m
gh=(1-e(j))/(m-E);
g=[g,gh];
end
Eh=0;
for nh=g
Eh=Eh+nh;
end
w=[];
for j=1:m
wh=g(j)/Eh;
w=[w,wh];
end
s=[];
for i=1:n
sh=w(i)*p(i,:);
shen=0;
for she=sh
shen=shen+she;
end
s=[s ,shen];
end