0% found this document useful (0 votes)
277 views3 pages

Appendix F Sample MATLAB Code For TOPSIS Method (Material Journal Bearing)

This MATLAB code implements the Technique for Order Preference by Similarity to Ideal Solution (TOPSIS) method to analyze and rank different bearing material alternatives. It defines the attributes, collects the data, normalizes the decision matrix, calculates the weighted normalized value matrix, and determines the relative closeness of each alternative to the ideal solution to obtain the ranking. The best alternative is displayed along with a bar chart of its weighted normalized values on each attribute.

Uploaded by

chupchap
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
277 views3 pages

Appendix F Sample MATLAB Code For TOPSIS Method (Material Journal Bearing)

This MATLAB code implements the Technique for Order Preference by Similarity to Ideal Solution (TOPSIS) method to analyze and rank different bearing material alternatives. It defines the attributes, collects the data, normalizes the decision matrix, calculates the weighted normalized value matrix, and determines the relative closeness of each alternative to the ideal solution to obtain the ranking. The best alternative is displayed along with a bar chart of its weighted normalized values on each attribute.

Uploaded by

chupchap
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Appendix F

Sample MATLAB code for TOPSIS method (Material Journal Bearing)

closeall
clearall
clc
fprintf('Selection of Bearing Material\n\n')
fprintf('Output of TOPSIS Method\n\n')
fprintf('The Attributes are:\n');
fprintf('MLC — Maximum Load Carrying CapacityXn')
fprintf('CONF — ConformabilityXn');
fprintf('EMB — Embeddability\n');
fprintf('COR — Corrosion Resistance\n')
fprintf('FS — Fatigue StrengrhXn')
fprintf{'TS — Tensile StrengrhXn')
fprintf('MOD — Modulus of ElasticityXn')
fprintf('LTE — Linear Thermal Expansion CoefficientXn')
fprintf{'DEN — DensityXnXn')
% Declare that a variable is 3eneficial or nonbeneficial; Beneficial==l,
NonBeneficial==0

Beneficial=[1 11111000];
% Data Matrix is given and its size is stored in m and n
B=[l 1 1 1 1 1 0 0 0];
fprintf('The Data Matrix is:\n\n')
A=[10342.5 4551 77.28 52 23 7.4; 8274 5441 68.94 29 20 10.1; 13789.5 4
4 1 2 77.28 54 30 8.6; ...
17236.9 4413 55.17 53 20 9.5; 27580 2244 213.8 97 18 8.9; 27580 1 1
4 5 310 110 18 8.8; ...
27580 2154 151.71 70 24 2.9; 27580 1255 158.6 72 20 10.5; 8274 5 5
1 2 68.94 70 22 9];
R=[1.00 0.8 0.5 0.6 0.5 0.6 0.2 0.3 0.4; 1.25 1.00 0.4 0.5 0.7 0.4 0.5 0.4
0.4; 2 2.5 1 0.5 0.6 0.6 0.4 0.5 0.3; ...
1.67 2 2 1 0.5 0.5 0.4 0.4 0.3; 2 1.43 1.67 2 1 0.5 0.5 0.6 0.4; 1.67 2.5
1.67 2 2 1 0.6 0.6 0.4; ...
5 2 2.5 2.5 2 1.67 1 0.4 0.7; 3.33 2.5 2.5 2.5 1.67 1.67 2.5 1 0.5; 2.5
2.5 3.33 3.33 2.5 2.5 1.43 2 1] ;
[m n] =size (A) ;
fprintf('Alternative MLC CONF EMB COR FS
TS MOD LTE DEN\n') ;

for i=l:m
fprintf{' %2d ',i)
for j=l:n
fprintf('%8.2f ',A(i,j))
end
fprintf('\n') ;
end
fprintf('\n')
fprintf('The Relative Importance Matrix is:\n\n')
fprintf('Alternative MLC CONF EMB COR FS
TS MOD LTE DEN\n');

for i=l:m
fprintf(' %2d ', i)
for j=l:n

140
fprintf('%8.2f *,R(i,j))
end
fprintf('\n');
end
fprintf('\n')
for j=l:n
suml=0;
for i=l:m
suml=suinl+A(i, j ) *A(i, j );
end
for i=l:m
N(i,j)=A(i,j)/sqrt(suml);
end
end
fprintf('The Normalized Decision Matrix is:\n\n')
fprintf('Alternative MLC CONF EMB COR FS
TS MOD LTE DEN\n’);

for i=l:m
fprintf(' %2d ',i)
for j=l:n .
fprintf('%8.2f ’,N(i,j))
end
fprintf('\n');
end
fprintf('\n')
[v d] =eig (R) ;
[maxeigen, position]=max(max(d));
w=v(:,position)';
for i=l:m
V(i,:)«w.*N(i,:);
end
for j=l:n
if B(j)==1
ideal(j)=max(V(:,j));
negideal(j)=min(V(:,j));
else
ideal(j)=min(V(:,j));
negideal(j)=max(V(:,j));
end
end
for i=l:n
siplus(i)=0;siminus(i)=0;
for j=l:n
siplus(i)=siplus(i)+(V(i,j)-ideal(j))^2;
siminus (i) =siminus (i) + (V (i, j ) -negideal (j ) )f'2;
end
end
siplus=sqrt(siplus);
siminus=sqrt(siminus);
fprintf('Relative closeness of alternatives to ideal solution:\n\n')
P=siminus./(siplus+siminus);
for i=l:m
fprintf('%7.4f ’,P(i))
end

141
[Q,i]=sort(P,'descend');
fprintf('\n\nRelative closeness sorted\n')
for j=l:m
fprintf('%7.4f ',Q(j))
end

fprintf('\n\n')
fprintf('The order of preference of different alternatives:\n\n')

for j=l:m
fprintf('%2d ',i{j))
end
fprintf('\n\n')
fprintf('The Best Alternative is %2d\n',i(l))
bar(N(i(1),:))
xlabel{'Attribute --- >')
ylabel('Weighted Normalized Value --- >')
legend('MLC, 'CONF', 'EMB', 'COR', 'FS', 'TS', 'MOD', 'LTE', 'DEN')

142

You might also like