matlab权重加大代码
时间: 2023-09-19 19:07:34 浏览: 80
下面是使用Matlab编写的计算权重的代码:
clc;
clear;
X = [0.4830,13.2682,0.0000,4.3646,5.1070;
0.4035,13.4909,39.0131,3.6151,5.5005;
0.8979,25.7776,9.0513,4.8920,7.5342;
0.5927,16.0245,13.2935,4.4529,6.5913];
[n,m] = size(X);
X(:,3) = min_best(X(:,3)); % 将极小型指标转化为加大型
xmin = min(X);
xmax = max(X);
xmaxmin = xmax - xmin;
Z = (X - xmin) ./ repmat(xmaxmin, n, 1); % 最大值最小值标准化,去除量纲
R = corrcoef(Z); % 计算相关系数矩阵,但要将相关系数矩阵都变成正相关
for i = 1:n
for j = 1:m
if R(i,j) < 0
R(i,j) = -R(i,j);
end
end
end
delta = zeros(1,m);
c = zeros(1,m);
for j = 1:m
delta(j) = std(Z(:,j));
c(j) = size(R,1) - sum(R(:,j));
end
C = delta .* c;
w = C ./ sum(C);
这段代码首先定义了一个矩阵X,然后对X进行了一系列的操作,包括将极小型指标转化为加大型,最大值最小值标准化,计算相关系数矩阵并将其变成正相关,最后计算权重w。
注意:代码中的min_best函数是子函数,用于将极小型指标转化为加大型。该函数接受一个向量x,并返回转化后的向量change_x。
希望这能帮到你!<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* *2* *3* [关于Critic确定权重的matlab代码和python代码](https://blog.csdn.net/stephen_curry300/article/details/106989729)[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: 100%"]
[ .reference_list ]
阅读全文