From 7a93f76da0c00c4fbc3e8f49d0c90b06175d9444 Mon Sep 17 00:00:00 2001 From: phzrjyvu9 <2026074240@qq.com> Date: Sun, 21 Jul 2024 22:51:33 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B1=82=E6=AC=A1=E5=88=86=E6=9E=90=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 姚安欣/AHP.m | 64 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 姚安欣/AHP.m diff --git a/姚安欣/AHP.m b/姚安欣/AHP.m new file mode 100644 index 0000000..743b7de --- /dev/null +++ b/姚安欣/AHP.m @@ -0,0 +1,64 @@ +%AHP步骤 + +clc,clear,close all; +A=[1,2,3,5 + 1/2,1,1/2,2 + 1/3,2,1,2 + 1/5,1/2,1/2,1]; +[row,col]=size(A); + +%判断矩阵一致性检验 +n=col; +maxlam=max(eig(A)); +RI=[0 0 0.58 0.90 1.12 1.24 1.32 1.41 1.45]; +CI=(maxlam-n)/(n-1); +CR=CI/RI(n); + +%判断矩阵确定权重 +for i=1:col + sumcol=sum(A(:,i)); + for j=1:row + A(j,i)=A(j,i)/sumcol; + end +end + +weig=zeros(row,1); +for i=1:row + sumrow=sum(A(i,:)); + weig(i)=sumrow/n; +end + +%各个指标归一化 按列单位化 +data= [1686.4 3183 12000 397 + 903.6 1916.4 3439.6 43 + 837.6 817.6 4748 1159 + 824.9 1296.4 12000 442 + 2110.2 1465.7 6199.5 228]; +[rowd,cold]=size(data); +for i=1:cold + sumcold=sum(data(:,i)); + for j=1:rowd + data(j,i)=data(j,i)/sumcold; + end +end + + +%按权重计算分数 + +score=data*weig; + + +projectNames={'老番茄','何同学','木鱼水心','凉风','罗翔'}; +figure; +bar(score);%条形图 + +set(gca, 'XTickLabel', projectNames); %每个条形图标签 +xlabel('博主'); +ylabel('加权总分'); +title('得分'); + +grid on; % 网格线 + + + +