|
1 | | -function [c,Dplus,Dminus]=topsis(data,p,w,w2,crit) |
| 1 | +function [c,Dplus,Dminus]=topsis(data,p,w,w2,crit,we) |
2 | 2 | x=data; |
3 | 3 | [m,n]=size(x); |
| 4 | +if nargin<6 |
| 5 | +we=ones(1,n); |
| 6 | +elseif nargin<5 |
| 7 | +crit=ones(1,n); |
| 8 | +end |
| 9 | + |
4 | 10 | a=zeros(m,n); |
5 | 11 | %Normalization to unit interval: |
6 | 12 | a=normalization(x); |
7 | | - |
| 13 | +%weigted normalized decision matrix: |
| 14 | +r=we.*a; |
8 | 15 | %Positive and negative ideal solutions: |
9 | 16 | PIS=zeros(1,n); |
10 | 17 | NIS=zeros(1,n); |
11 | 18 | for j=1:n |
12 | 19 | if crit(j)==1 |
13 | | - PIS(j)=recursivetconorm(a(:,j)',w); |
14 | | - NIS(j)=recursivetnorm(a(:,j),w2); |
| 20 | + PIS(j)=recursivetconorm(r(:,j)',w); |
| 21 | + NIS(j)=recursivetnorm(r(:,j),w2); |
15 | 22 | else |
16 | | - NIS(j)=recursivetconorm(a(:,j)',w); |
17 | | - PIS(j)=recursivetnorm(a(:,j),w2); |
| 23 | + NIS(j)=recursivetconorm(r(:,j)',w); |
| 24 | + PIS(j)=recursivetnorm(r(:,j),w2); |
18 | 25 | end |
19 | 26 | end |
20 | 27 |
|
21 | 28 | %Distances to PIS and NIS |
22 | 29 | DPISB=zeros(1,m); |
23 | 30 | DNISB=zeros(1,m); |
24 | 31 | for i=1:m |
25 | | - Dplus(i)=distM(PIS,a(i,:),p); |
26 | | - Dminus(i)=distM(NIS,a(i,:),p); |
| 32 | + Dplus(i)=distM(PIS,r(i,:),p); |
| 33 | + Dminus(i)=distM(NIS,r(i,:),p); |
27 | 34 | end |
28 | 35 | %Closeness coefficient: |
29 | 36 | c=zeros(1,m); |
|
0 commit comments