功能描述:
%層次分析法(AHP)
disp('請輸入判斷矩陣A(n階)');
A = input('A=');
[n,n] = size(A);
x = ones(n,100);
y = ones(n,100);
m = zeros(1,100);
m(1) = max(x(:,1));
y(:,1) = x(:,1);
x(:,2) = A*y(:,1);
m(2) = max(x(:,2));
y(:,2) = x(:,2)/m(2);
p=0.0001; i=2; k=abs(m(2)-m(1));
while k>p
i=i+1;
x(:,i) = A*y(:,i-1);
m(i) = max(x(:,i));
y(:,i) = x(:,i)/m(i);
k=abs(m(i)-m(i-1));
end
a = sum(y(:,i));
w = y(:,i)/a;
t = m(i);
disp(w);
%一致性檢驗
CI = (t-n)/(n-1);
RI = [0 0 0.52 0.89 1.12 1.36 1.41 1.46 1.49 1.52 1.54 1.56 1.58 1.59];
CR = CI/RI(n);
if CR<0.10
disp('此矩陣一致性可以接受!');
disp('CI=');disp(CI);
disp('CR=');disp(CR);
end
聯(lián)系:highspeedlogic
QQ :1224848052
微信:HuangL1121
郵箱:1224848052@qq.com
網(wǎng)站:http://www.mat7lab.com/
網(wǎng)站:http://www.hslogic.com/
微信掃一掃:
|