熵权法topsismatlab代码
时间: 2023-09-24 10:07:25 浏览: 85
熵权法matlab代码
5星 · 资源好评率100%
熵权法topsismatlab代码如下所示:
```matlab
clearvars clc
format short
format compact
X = 0.5*log(abs(100*(rand(300,4))));
sqrt(abs(100*(rand(300,4))));
Variable = {'X1','X2','X3','X4','权重之和'}';
[Wj2,T1,T2_sort,Ej = ShangTopsis(X,Variable);
function [Wj2,T1,T2_sort,Ej = ShangTopsis(X,Variable)
[m,n = size(X);
X_PO = (X-min(X))./range(X); X_NE = (max(X)-X)./range(X);
% 熵法计算各指标的权重
P = X_PO./sum(X_PO);
E = sum(P.*log(P));
W = (1-E)./(n-E);
Wj = W./sum(W);
% TOPSIS法计算综合评价指标
A = X_PO.*repmat(Wj',m,1);
B = X_NE.*repmat(Wj',m,1);
T1 = sqrt(sum(A.^2,2));
T2 = sqrt(sum(B.^2,2));
R = T2./(T1+T2);
[~,T2_sort = sort(R,'descend');
% 计算综合评价指标的效益值
Ej = T2./sum(T2);
Wj2 = Wj';
end
```
这段代码实现了熵权法TOPSIS算法,包括了数据正向化和负向化、计算各指标的权重、计算综合评价指标以及计算综合评价指标的效益值。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
阅读全文