+1,j+1));
z(i,j)=1000; end; end; end;
[ii,jj]=find(z==1000); disp(ii');disp(jj');
subplot(2,2,k),scatter(ii,jj,'*'),title(ss{k}) end
4.2 重金属元素汞、镍、铅、锌的污染源分布图的MATLAB程序: A=xlsread('F:\\A\\cumcm2011A附件_数据.xls',1,'A4:E322'); B=xlsread('F:\\A\\cumcm2011A附件_数据.xls',2,'B4:I322'); ss={'As ','Cd','Cr ','Cu','Hg','Ni','Pb','Zn'}; x=A(:,2);y=A(:,3); for k=5:8 z=B(:,k);
[X,Y,Z]=griddata(x,y,z,linspace(0,30000)',linspace(0,20000),'v4');%插值 z=Z';
for i=2:99 for j=2:99 if
(z(i,j)>z(i-1,j))&&(z(i,j)>z(i+1,j))&&(z(i,j)>z(i,j+1))&&(z(i,j)>z(i,j-1))&&(z(i,j)>z(i-1,j-1))&&(z(i,j)>z(i-1,j+1))&&(z(i,j)>z(i+1,j-1))&&(z(i,j)>z(i+1,j+1));
z(i,j)=1000; end; end; end;
[ii,jj]=find(z==1000); disp(ii');disp(jj');
subplot(2,2,k-4),scatter(ii,jj,'*'),title(ss{k}) end
附录五:
筛选污染源的MATLAB程序(以砷为例,其它元素的程序只需调整参数即可): A=xlsread('F:\\A\\cumcm2011A附件_数据.xls',1,'A4:E322'); B=xlsread('F:\\A\\cumcm2011A附件_数据.xls',2,'B4:I322'); ss={'As ','Cd','Cr ','Cu','Hg','Ni','Pb','Zn'}; x=A(:,2);y=A(:,3); z=B(:,1);
[X,Y,Z]=griddata(x,y,z,linspace(0,30000)',linspace(0,20000),'v4');%插值 z=Z'; k=z;
for i=2:99 for j=2:99
19
if
(z(i,j)>z(i-1,j))&&(z(i,j)>z(i+1,j))&&(z(i,j)>z(i,j+1))&&(z(i,j)>z(i,j-1))&&(z(i,j)>z(i-1,j-1))&&(z(i,j)>z(i-1,j+1))&&(z(i,j)>z(i+1,j-1))&&(z(i,j)>z(i+1,j+1));
z(i,j)=1000; end; end; end;
[ii,jj]=find(z==1000); c=[ii,jj]; n=size(ii,1); for i=1:n
kk(i)=k(ii(i),jj(i)); end pp=kk';
kkk=find(kk>500); kkk=kkk'; n=size(kkk,1) for i=1:n
rr(i)=pp(kkk(i)); end rr
for i=1:n
cc(i,1)=c(kkk(i),1); cc(i,2)=c(kkk(i),2); end
scatter(cc(:,1),cc(:,2),'*') axis([0,100,0,100]) title(ss{1})
20