matlab 三法求矩阵权重(算数平均法求权重,几何平均法求权重,特征值法求权重)

三法求矩阵权重

例子为3*3的矩阵,可根据需要修改

算数平均法求权重

clc,clear;
judge=[1,6/9,7/8;
    9/6,1,9/7;
    8/7,7/9,1;];
w=zeros(3,3);
for i=1:3
    for j=1:3
        w(i,j)=judge(i,j)/(judge(1,j)+judge(2,j)+judge(3,j));
    end
end
[V,D]=eig(judge)

几何平均法求权重

clc,clear;
judge=[1,6/9,7/8;
    9/6,1,9/7;
    8/7,7/9,1;];
r=zeros(3,1);
w=zeros(1,3);
r(1)=judge(1)*judge(4)*judge(7);
r(2)=judge(2)*judge(5)*judge(8);
r(3)=judge(3)*judge(6)*judge(9);
r
r(1)=r(1)^(1/3);
r(2)=r(2)^(1/3);
r(3)=r(3)^(1/3);
r
w(1)=r(1)/(r(1)+r(2)+r(3));
w(2)=r(2)/(r(1)+r(2)+r(3));
w(3)=r(3)/(r(1)+r(2)+r(3));
w

特征值法求权重

clc,clear;
judge=[1,6/9,7/8;
    9/6,1,9/7;
    8/7,7/9,1;];
w=zeros(3,3);
for i=1:3
    for j=1:3
        w(i,j)=judge(i,j)/(judge(1,j)+judge(2,j)+judge(3,j));
    end
end
[V,D]=eig(judge)
%先运行以上程序,在D中找出矩阵的最大特征值3,对应找到V中与最大特征值3对应的特征向量,在接下来的代码中写入该特征向量
v=[0.46914,0.69889,0.53986];
w1=zeros(1,3);
w1(1)=v(1)/(v(1)+v(2)+v(3));
w1(2)=v(2)/(v(1)+v(2)+v(3));
w1(3)=v(3)/(v(1)+v(2)+v(3));
w1

其中,v是在w1即为
一致性比率(Consistency Ratio):C.R.=C.I./R.I.

若C.R.<0.1,判断矩阵B具有满意一致性;
若C.R.>=0.1,判断矩阵B不具有满意一致性,需要重新构造,直到满意为止。

最后要通过一致性检验才行,基本上三法求得的权重相等

当判断矩阵是4*4时

clc,clear;
m=[1 8/6 8/5 8/9;
    6/8 1 6/5 6/9;
    5/8 5/6 1 5/9;
    9/8 9/6 9/5 1];
[V,D]=eig(m);
wei=zeros(4,4);
for i=1:4
    for j=1:4
        wei(i,j)=m(i,j)/(m(1,j)+m(2,j)+m(3,j)+m(4,j));
    end
end
wei

clc,clear;
judge=[1 8/6 8/5 8/9;
    6/8 1 6/5 6/9;
    5/8 5/6 1 5/9;
    9/8 9/6 9/5 1];
r=zeros(4,1);
w=zeros(1,4);
r(1)=judge(1)*judge(5)*judge(9)*judge(13);
r(2)=judge(2)*judge(6)*judge(10)*judge(14);
r(3)=judge(3)*judge(7)*judge(11)*judge(15);
r(4)=judge(4)*judge(8)*judge(12)*judge(16);
r(1)=r(1)^(1/4);
r(2)=r(2)^(1/4);
r(3)=r(3)^(1/4);
r(4)=r(4)^(1/4);
r
w(1)=r(1)/(r(1)+r(2)+r(3)+r(4));
w(2)=r(2)/(r(1)+r(2)+r(3)+r(4));
w(3)=r(3)/(r(1)+r(2)+r(3)+r(4));
w(4)=r(4)/(r(1)+r(2)+r(3)+r(4));
w

clc,clear;
judge=[1 8/6 8/5 8/9;
    6/8 1 6/5 6/9;
    5/8 5/6 1 5/9;
    9/8 9/6 9/5 1];
w=zeros(4,4);
for i=1:4
    for j=1:4
        w(i,j)=judge(i,j)/(judge(1,j)+judge(2,j)+judge(3,j)+judge(4,j));
    end
end
[V,D]=eig(judge)
v=[0.5574,0.4180,0.3484,0.6271];
w1=zeros(1,4);
w1(1)=v(1)/(v(1)+v(2)+v(3)+v(4));
w1(2)=v(2)/(v(1)+v(2)+v(3)+v(4));
w1(3)=v(3)/(v(1)+v(2)+v(3)+v(4));
w1(4)=v(4)/(v(1)+v(2)+v(3)+v(4));
w1
    原文作者:CTGU_daffodil
    原文地址: https://blog.csdn.net/zhanghanqmx/article/details/119391099
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞