变异系数法求权重matlab代码clear;clc;[data1,header1]=xlsread('statistic1.xlsx','ECO');%必须将statistic.xlsx至于默认文件下,或者给出完整路径[data2,header2]=xlsread('statistic2.xlsx','ECO');%data1为10个city数据,data2位20个city数据size1=size(data1);m1=size1(1,1);d1=data1;d2=data2;size2=size(data2);m2=size2(1,1);judge=[461213161718];%需要极大化处理的指标位置forj=1:length(judge)%将极小型数据指标极大化,便于计算得分d2(:,judge(1,j))=1./d2(:,judge(1,j));d1(:,judge(1,j))=1./d1(:,judge(1,j));endsum2=sum(d2);sum1=sum(d1);data22=[];data11=[];fori=1:m2%数据归一化处理data22=[data22;d2(i,:)./sum2];endfori=1:m1data11=[data11;d1(i,:)./sum1];endR=data22;deta=std(R)./mean(R);%计算变异系数w=deta/sum(deta);%score=data1*w';%综合得分score=data11*w';output=[mean(R);deta;w];score1=5+(score-min(score)+std(score)/length(score))./(max(score)-min(score)+mean(score)/length(score))*95;%功效系数法,使得得分在[5,100][ScoreFinal,index]=sort(score1,'descend');%降序排列sort=[ScoreFinal,index];%得分与排名xlswrite('statistic1.xlsx',output,'变异系数');%输出均值mean,标准差std,权重w到statistic1.xlsxxlswrite('statistic1.xlsx',sort,'变异sortDescend');%输出得分与排名statistic1.xlsx