topsis评价法程序functiony=Topsis1(A,ave,m)%ave:元素的平均值。m:背景值范围min~max。y=D_count(A);rr=A(:,6:13);r=zeros(5,8);I=zeros(5,8);sum=zeros(1,5);fori=1:5ifi==1a=1;b=y(i);elsea=y(i-1)+1;b=y(i);endforj=1:8fork=a:bI(i,j)=I(i,j)+rr(k,j)/(avg(j)*(b-a+1));endendendfori=1:5forj=1:8sum(i)=sum(i)+I(i,j);endendfori=1:5%权重forj=1:8w(i,j)=I(i,j)/sum(i);endendfori=1:5ifi==1a=1;b=y(i);elsea=y(i-1)+1;b=y(i);endforj=a:bfork=1:8ifrr(j,k)m(k,1)rr(j,k)=abs(rr(j,k)-m(k,1));elseifrr(j,k)m(k,2)rr(j,k)=abs(rr(j,k)-m(k,2));elserr(j,k)=0;endr(i,k)=r(i,k)+rr(j,k);%先加起来再取平均endendfork=1:8r(i,k)=r(i,k)/(b-a+1);endendfori=1:5forj=1:8if(max(r(:,j))-min(r(:,j)))==0x(i,j)=inf;elsex(i,j)=(r(i,j)-min(r(:,j)))/(max(r(:,j))-min(r(:,j)));endendendfori=1:5forj=1:8z(i,j)=w(i,j)*x(i,j);endendforj=1:8z_inter(j)=min(z(:,j));z_neg(j)=max(z(:,j));endfori=1:5sum1=0;sum2=0;forj=1:8sum1=sum1+(z(i,j)-z_inter(j))^2;sum2=sum2+(z(i,j)-z_neg(j))^2;endd_inter(i)=sqrt(sum1);d_neg(i)=sqrt(sum2);endfori=1:5y(i)=d_inter(i)/(d_inter(i)+d_neg(i));end