matlab熵权法代码
时间: 2023-08-29 20:11:58 浏览: 211
shangquan.zip_S2M7_hornvfw_matlab_stars4u_熵权法代码
以下是MATLAB中使用熵权法进行计算的示例代码:
```matlab
%% 归一化
[i,j = size(R); % 输入矩阵的大小,i为对象个数,j为指标个数
n = i;
m = j;
k = 1/log(i); % 求k
Rmin = min(R);
R1 = Rmin;
Rmax = max(R);
R2 = Rmax;
A = max(R) - min(R); % 正向指标
y = repmat(A, n, 1); % repmat(A,a,1) a需要根据矩阵自行修改,等于备选个数
y2 = repmat(Rmin, n, 1); % repmat(Rmin,a,1) a需要根据矩阵自行修改,等于备选个数
y3 = 1./y;
x = (R-y2).*y3;
%% 求各指标的信息熵
S1 = sum(x);
S2 = repmat(sum(x), n, 1); % repmat(sum(x),a,1) a需要根据矩阵自行修改,等于备选个数
pij = x./S2;
lnpij = zeros(n, m);
for i = 1:n
for j = 1:m
if pij(i,j) == 0
lnpij(i,j) = 0;
else
lnpij(i,j) = log(pij(i,j));
end
end
end
ej = -k*(sum(pij.*lnpij, 1)); % 计算熵值
```
希望这段代码能够帮助您进行MATLAB中熵权法的计算。请注意,代码中的变量R表示输入矩阵,您需要根据实际情况进行相应的调整和修改。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* *2* [matlab 熵权法代码](https://blog.csdn.net/Zero981015/article/details/112972870)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"]
- *3* [MATLAB中的Cell数组:用法解析与示例代码](https://download.csdn.net/download/weixin_41784475/88226800)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"]
[ .reference_list ]
阅读全文