%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%2005年A题长江水污染%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%A%灰色预测clc,clear;%X=[6.77.37.85.14.67.8];%0%%X=[9.613.312.825.426.522.523.5];X=[174179183207234220.5256270285];%X=log(x+1);n=length(X);%计算矩阵长度x1=cumsum(X);%累加后的矩阵fori=2:nrou(i)=X(i)/x1(i-1);%光滑性检验endfori=2:nsigma(i)=x1(i)/x1(i-1);%准指数检验endi=2:n;y(i-1)=X(i);y1=y';%将原行向量转化成对应列向量i=1:n-1;%计算数据矩阵B的第一列数据C(i)=-0.5*(x1(i)+x1(i+1));B=[C'ones(n-1,1)];%构造矩阵Bau=((B'*B)\B')*y1;%计算参数a,u矩阵au;a=au(1);u=au(2);i=1:n+10;%计算预测累加数列的值ago(i)=(X(1)-u/a)*exp(-a*(i-1))+u/a;%累加数列值yc(1)=ago(1);i=1:n+10-1;%还原数列的值yc(i+1)=ago(i+1)-ago(i);i=2:n;error(i)=yc(i)-X(i);%计算残差值yc(1)=ago(1);i=1:n;%修正的还原数列值!!!!!yc(i+1)=ago(i+1)-ago(i);%预测值c=std(error)/std(X);%计算后验差比p=0;fori=1:2nif(abs(error(i)-mean(error))0.6745*std(X))p=p+1;endendp=p/(n-1);%小误差概率w1=min(abs(error));w2=max(abs(error));i=1:n;w(i)=(w1+0.5*w2)./(abs(error(i))+0.5*w2);w=sum(w)/(n);%关联度disp('光滑性检验')rou%光滑性检验disp('准指数检验')sigma%准指数检验disp('参数a,u')au%参数a,udisp('累加数列ago的值')%ago%累加数列ago的值x1disp('原始序列')X%原始序列disp('预测数值')yc%预测数值disp('残差值')error%残差值disp('后验差比值')c%后验差比值disp('小误差概率的值')p%小误差概率的值disp('关联度')w%关联度wQQ=abs((error./X)*100)%相对误差百分比%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%BTOPSIS评价模型clc,clear;%读取表格中的相关数据num2=xlsread('changjiang.xlsx','A2:A18');%DOnum3=xlsread('changjiang.xlsx','B2:B18');%CODMnnum4=xlsread('changjiang.xlsx','C2:C18');%NH3-Nb=max(num2)-num2;%1./num2;%对DO对应数据进行去倒数处理r2=(b-min(b))./(max(b)-min(b));r3=(num3-min(num3))./(max(num3)-min(num3));r4=(num4-min(num4))./(max(num4)-min(num4));R=[r2r3r4];%将所有计算结果返回矩阵R%构建加权规范决策矩阵ZQ=[0.020.150.400.720.911];%对第2列数据处理b2=size(num2);b2(1);fori=1:1:b2(1);ifnum2(i)=7.5;num2(i)=Q(1);elseifnum2(i)=6&&num2(i)7;num2(i)=Q(2);elseifnum2(i)=5&&num2(i)6;num2(i)=Q(3);elseifnum2(i)=3&&num2(i)5;num2(i)=Q(4);elseifnum2(i)=2&&num2(i)3;num2(i)=Q(5);elseifnum2(i)=0&&num2(i)2;num2(i)=Q(6);endendnum2;%对第3列数据处理b3=size(num3);b3(1);fori=1:1:b3(1);ifnum3(i)=2;num3(i)=Q(1);elseifnum3(i)2&&num3(i)=4;num3(i)=Q(2);elseifnum3(i)4&&num3(i)=6;num3(i)=Q(3);elseifnum3(i)6&&num3(i)=10;num3(i)=Q(4);elseifnum3(i)10&&num3(i)=15;num3(i)=Q(5);elseifnum3(i)15;num3(i)=Q(6);endendnum3;%对第4列数据进行处理b4=size(num4);b4(1);fori=1:1:b4(1);ifnum4(i)=0.15;num4(i)=Q(1);elseifnum4(i)0.15&&num4(i)=0.5;num4(i)=Q(2);elseifnum4(i)0.5&&num4(i)=1;num4(i)=Q(3);elseifnum4(i)1&&num4(i)=1.5;num4(i)=Q(4);elseifnum4(i)1.5&&num4(i)=2;num4(i)=Q(5);elseifnum4(i)2;num4(i)=Q(6);endendnum4;W=[num2num3num4];%[num1num2num3num4];%权重矩阵%确定正、负理想解r11=min(R(:,1));%正理想解r12=min(R(:,2));r13=min(R(:,3));%步骤五:计算距离d11=(R(:,1)-r11).^2;d12=(R(:,2)-r12).^2;d13=(R(:,3)-r13).^2;d01=[d11d12d13];P1=W.*d01;%得到评价矩阵Pingjia=(sum(P1'))';%最终评价矩阵17*1Pingjia%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%C时间序列模型clc,clear;A=[...];%待处理数据a=A';figuresubplot(1,2,1)autocorr(A)title('自相关函数图')subplot(1,2,2)parcorr(A)title('偏相关函数图')da=a;n=length(da);fori=0:2forj=0:3spec=garchset('R',i,'M',j,'Display','off');[coeffX,errorsX,LLFX]=garchfit(spec,da);num=garchcount(coeffX);[aic,bic]=aicbic(LLFX,num,n);fprintf('R=%d,M=%d,AIC=%f,BIC=%f\n',i,j,aic,bic);endend%计算AIC的循环可以省去不要r=input('输入阶数R=');m=input('输入阶数M=');spec2=garchset('R',r,'M',m,'Display','off');[coeffX,errorsX,LLFX]=garchfit(spec2,da);[sigmaForecast,w_Forecast]=garchpred(coeffX,da,5);w_Forecastx_pred=a(end)+cumsum(w_Forecast)%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%2006年B题艾滋病%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%投入产出模型ADEA1clc,clear;x=xlsread('111.xls','C13:F32');%多目标输入y=xlsread('111.xls','G13:G32');%多目标产出X=x';Y=y';n=size(X',1);m=size(X,1);s=size(Y,1);A=[-X'Y'];b=zeros(n,1);LB=zeros(m+s,1);UB=[];fori=1:n;f=[zeros(1,m)-Y(:,i)'];Aeq=[X(:,i)'zeros(1,s)];beq=1;w(:,i)=linprog(f,A,b,Aeq,beq,LB,UB);%解线性规划,得到DMUi的最佳权向量wiE(i,i)=Y(:,i)'*w(m+1:m+s,i);%求出DMUi的相对效率值Eiiendfori=1:20xiaolv(i)=E(i,i);endw;%输出最佳权向量E;%输出相对效率值xiaolvomega=w(1:m,:);%输出投入权向量mu=w(m+1:m+s,:);%输出产出权向量%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%BDEA2clc,clear;X=[...];%多指标输入矩阵XY=[...];%多指标输出矩阵Yn=size(X',1);m=size(X,1);s=size(Y,1);epsilon=10^-10;%定义非阿基米德无穷小f=[zeros(1,n)-epsilon*ones(1,m+s)1];A=zeros(1,n+m+s+1);b=0;LB=zeros(n+m+s+1,1);UB=[];LB(n+m+s+1)=-Inf;fori=1:n;Aeq=[Xeye(m)zeros(m,s)-X(:,i);Yzeros(s,m)-eye(s)zeros(s,1)];beq=[zeros(m,1);Y(:,i)];w(:,i)=linprog(f,A,b,Aeq,beq,LB,UB);%解线性规划,的DMUi的最佳权向量wiendw%输出最佳权向量lambda=w(1:n,:)%输出.*s_minus=w(n+1:n+m,:)%输出S*-s_plus=w(n+m+1:n+m+s,:)%输出S*+theta=w(n+m+s+1,:)%输出.*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%2011年A题重金属%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%A计算灰色关联度clc,clear;A=xlsread('三问.xlsx','N2:O315');B=[3.635];%母序列[m,n]=size(A);derta=zeros(m,n);fori=1:nderta(:,i)=abs(A(:,i)-B(i));enddertafori=1:na(:,i)=min(derta(:,i));b(:,i)=max(derta(:,i));a=min(a);b=max(b);endabv=(a+0.5*b)./(derta+0.5*b)Q=[0.00420.3341];%权重q=Q./sum(Q);fori=1:nU(:,i)=v(:,1)*q(i);endu=sum(U');u'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%B绘制重金属污染物的空间分布图(三维立体图)clcclearcloseallD=xlsread('2011A附件_数据.xls','A2:F314');x=D(:,2);y=D(:,3);z=D(:,4);C=D(:,6);c=D(:,5);xi=l