topsis mtalab
时间: 2023-10-12 20:04:53 浏览: 83
TOPSIS算法是一种多属性决策方法,用于评估多个方案的优劣。其基本思想是通过归一化后的原始数据矩阵,找出最优方案和最劣方案,然后计算各评价对象与最优方案的距离,以此作为评价优劣的依据。\[2\]
在MATLAB中,可以使用以下代码实现TOPSIS算法:
```matlab
clc,clear;
x=\[21584 76.7 7.3 1.01 78.3 97.5 2.0;
24372 86.3 7.4 0.80 91.1 98.0 2.0;
22041 81.8 7.3 0.62 91.1 97.3 3.2;
21115 84.5 6.9 0.60 90.2 97.7 2.9;
24633 90.3 6.9 0.25 95.5 97.9 3.6\];
\[n,m\]=size(x);
% 将3,4,7的低优指标去倒数转化为高优指标并且把所有指标换成接近的大小
x(:,1)=x(:,1)/100;
x(:,3)=(1./x(:,3))*100;
x(:,4)=(1./x(:,4))*100;
x(:,7)=(1./x(:,7))*100;
% 主要是要将其转化为极大型指标
zh=zeros(1,m);
d1=zeros(1,n); %最小值矩阵
d2=zeros(1,n); %最大值矩阵
c=zeros(1,n); %接近程度
% 标准化
for i=1:m
for j=1:n
zh(i)=zh(i)+x(j,i)^2;
end
end
for i=1:m
for j=1:n
x(j,i)=x(j,i)/sqrt(zh(i));
end
end
% 计算距离
xx=min(x);
dd=max(x);
for i=1:n
for j=1:m
d1(i)=d1(i)+(x(i,j)-xx(j))^2;
end
d1(i)=sqrt(d1(i));
end
for i=1:n
for j=1:m
d2(i)=d2(i)+(x(i,j)-dd(j))^2;
end
d2(i)=sqrt(d2(i));
end
% 计算接近程度
for i=1:n
c(i)=d1(i)/(d2(i)+d1(i));
end
\[sf,ind\]=sort(c,'descend'); %按降序排序
```
以上是一个简单的TOPSIS算法的MATLAB实现示例。你可以根据自己的数据进行相应的修改和调整。\[2\]
#### 引用[.reference_title]
- *1* [【数学模型】TOPSIS](https://blog.csdn.net/suic009/article/details/126138524)[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^v91^koosearch_v1,239^v3^insert_chatgpt"}} ] [.reference_item]
- *2* [Topsis 模型](https://blog.csdn.net/weixin_62558615/article/details/128815537)[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^v91^koosearch_v1,239^v3^insert_chatgpt"}} ] [.reference_item]
- *3* [TOPSIS法 —— matlab](https://blog.csdn.net/qq_25990967/article/details/122754308)[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^v91^koosearch_v1,239^v3^insert_chatgpt"}} ] [.reference_item]
[ .reference_list ]
阅读全文