当前位置:网站首页>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')
边栏推荐
- 509. Fibonacci Number. Sol
- Binary tree (II) -- code implementation of heap
- d3dx9_ What if 29.dll is missing? System missing d3dx9_ Solution of 29.dll file
- Distance from point to line intersection and included angle of line
- 分布式解决方案选型
- New 3D particle function in QT 6.3
- Character conversion PTA
- FBO and RBO disappeared in webgpu
- BFC block level formatting context
- [groovy] groovy dynamic language features (automatic type inference of function arguments in groovy | precautions for function dynamic parameters)
猜你喜欢
Arduino measures AC current
Win11 runs CMD to prompt the solution of "the requested operation needs to be promoted"
MySQL服务莫名宕机的解决方案
Starting from 1.5, build a micro Service Framework -- log tracking traceid
Business introduction of Zhengda international futures company
谷歌地图案例
a-tree 树的全部展开和收起
90后测试员:“入职阿里,这一次,我决定不在跳槽了”
Overview of Fourier analysis
The countdown to the launch of metaverse ape is hot
随机推荐
Postman core function analysis - parameterization and test report
[groovy] groovy dynamic language features (automatic type inference of function arguments in groovy | precautions for function dynamic parameters)
Post-90s tester: "after joining Ali, this time, I decided not to change jobs."
[groovy] mop meta object protocol and meta programming (execute groovy methods through metamethod invoke)
Global and Chinese markets for welding products 2022-2028: Research Report on technology, participants, trends, market size and share
二叉树(三)——堆排序优化、TOP K问题
How can Bluetooth in notebook computer be used to connect headphones
344. Reverse String. Sol
鏈錶之雙指針(快慢指針,先後指針,首尾指針)
The new content of the text component can be added through the tag_ Config set foreground and background colors
2022 Software Test Engineer salary increase strategy, how to reach 30K in three years
The code generator has deoptimised the styling of xx/typescript. js as it exceeds the max of 500kb
Hcip day 16
The introduction to go language is very simple: String
Draw a red lantern with MATLAB
Arduino measures AC current
Request preview display of binary data and Base64 format data
Function default parameters, function placeholder parameters, function overloading and precautions
Platformio create libopencm3 + FreeRTOS project
Metaverse Ape猿界应邀出席2022·粤港澳大湾区元宇宙和web3.0主题峰会,分享猿界在Web3时代从技术到应用的文明进化历程