当前位置:网站首页>TOPSIS code part of good and bad solution distance method
TOPSIS code part of good and bad solution distance method
2022-07-05 22:43:00 【jujuye】
1 Copy data to workspace , And named it X
2 Determine whether you need to forward
[n,m]=size(X);
disp([' share 'num2str(n)' Two evaluation objects ,'num2str(m)' Evaluation indicators '])
judge=input([' this 'num2str(m)' Whether the indicators need to be processed forward , Please enter 1, No, please enter 0:']);
if judge == 1
Position = input(' Please enter the column that needs forward processing , for example :[2,3,6]');
disp(' Please enter the type to be processed (1: Very small ,2: The middle type ,3: Interval type )')
Type = input(' for example : The first 2 Columns are very small , The first 3 Columns are interval type , The first 6 Columns are intermediate , enter [1,3,2]:')
for i = 1:size(Position,2)
X(:,Position(i)) = Positivization(X(:,Position(i)),Type(i),Position(i));
end
disp(' The forward matrix X = ')
disp(X)
end
Definition Positivization function
% Definition Positivization
function[posit_x] = Positivization(x,type,i)
if type == 1
disp([' The first 'num2str(i)' Columns are very small , Is moving forward '])
posit_x = Min2Max(x);
disp([' The first 'num2str(i)' Column miniaturization forward processing is complete '])
disp('~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~')
elseif type == 2
disp([' The first 'num2str(i)' Columns are intermediate , Is moving forward '])
best = input(' Please enter the best value :')
posit_x = Mid2Max(x,best);
disp([' The first 'num2str(i)' The forward processing of column intermediate type is completed '])
disp('~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~')
elseif type == 3
disp([' The first 'num2str(i)' Columns are interval type , Is moving forward '])
posit_x = Inter2Max(x,a,b);
disp([' The first 'num2str(i)' Column interval type forward processing completed '])
disp('~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~')
else
disp(' error ')
end
end
Definition Min2Max function
% Definition Min2Max function
function[posit_x] = Min2Max(x)
posit_x = max(x) - x;
end
Definition Mid2Max function
% Definition Mid2Max function
function[posit_x] = Mid2Max(x,best)
M = max(abs(x-best));
posit_x = 1-abs(x-best)/M;
end
Definition Inter2Max function
% Definition Inter2Max function
function [posit_x] = Inter2Max(x,a,b)
r_x = size(x,1);
M = max([a-min(x),max(x)-b]);
posit_x = zeros(r_x,1);
for i = 1:r_x
if x(i) < a
posit_x(i) = 1-(a-x(i))/M;
elseif x(i) > b
posit_x(i) = 1-(x(i)-b)/M;
else
posit_x(i) = 1;
end
end
end
3 Normalize the forward matrix
Z=X./repmat(sum(X.*X).^0.5,n,1);
disp(' Standardized matrix Z=')
disp(Z)
4 Calculate the distance from the maximum and the distance from the minimum , And calculate the score
D_P = sum([(Z-repmat(max(Z),n,1)).^2],2).^0.5
D_N = sum([(Z-repmat(min(Z),n,1)).^2],2).^0.5
S=D_N./(D_P+D_N);% Non normalized score
disp(' The final score is :')
stand_S = S/sum(S)
[sorted_S,index] = sort(stand_S,'descend')
边栏推荐
- Arduino 测量交流电流
- 第一讲:蛇形矩阵
- 2022 Software Test Engineer salary increase strategy, how to reach 30K in three years
- Sub total of Pico development
- QT creator 7 beta release
- Usage Summary of scriptable object in unity
- 鏈錶之雙指針(快慢指針,先後指針,首尾指針)
- Solve the problem of "no input file specified" when ThinkPHP starts
- Binary tree (III) -- heap sort optimization, top k problem
- All expansion and collapse of a-tree
猜你喜欢
[untitled]
[groovy] groovy dynamic language features (automatic type inference of function arguments in groovy | precautions for function dynamic parameters)
Metasploit(msf)利用ms17_010(永恒之蓝)出现Encoding::UndefinedConversionError问题
[error record] groovy function parameter dynamic type error (guess: groovy.lang.missingmethodexception: no signature of method)
What changes has Web3 brought to the Internet?
傅里叶分析概述
Damn, window in ie open()
What if the files on the USB flash disk cannot be deleted? Win11 unable to delete U disk file solution tutorial
Metaverse Ape上线倒计时,推荐活动火爆进行
从 1.5 开始搭建一个微服务框架——日志追踪 traceId
随机推荐
我把开源项目alinesno-cloud-service关闭了
[agc009e] eternal average - conclusion, DP
How to reverse a string fromCharCode? - How to reverse String. fromCharCode?
Function default parameters, function placeholder parameters, function overloading and precautions
509. Fibonacci Number. Sol
Navigation day answer applet: preliminary competition of navigation knowledge competition
Sparse array [matrix]
Oracle is sorted by creation time. If the creation time is empty, the record is placed last
EasyCVR集群部署如何解决项目中的海量视频接入与大并发需求?
IIC bus realizes client device
Double pointeur de liste liée (pointeur rapide et lent, pointeur séquentiel, pointeur de tête et de queue)
Damn, window in ie open()
Record several frequently asked questions (202207)
解决thinkphp启动时“No input file specified”的问题
如何快速体验OneOS
傅里叶分析概述
What changes has Web3 brought to the Internet?
实战:fabric 用户证书吊销操作流程
Global and Chinese markets of tantalum heat exchangers 2022-2028: Research Report on technology, participants, trends, market size and share
What if win11 is missing a DLL file? Win11 system cannot find DLL file repair method