corrcoef
x=linspace(0,10);
y=x+rand(size(x));
scatter(x,y)
h=lsline;
set(h,‘LineWidth‘,3,‘LineStyle‘,‘--‘,‘Color‘,[1 0 1])
pm10=[352,179,383,463,670,451,426,302,566]
pm25=[251,93,189,262,427,284,264,177,346]
plot(pm10,pm25,‘+‘);//绘出散点图
lsline;//根据散点图绘出直线
a=corrcoef(pm10,pm25);//获取相关系数矩阵
s=[‘pm10‘,‘pm25‘]
text(pm10,pm25,s);//在线上加标注
title(‘pm10、pm25相关性分析‘);
legend(‘pm10‘,‘pm25‘);
xlabel(‘PM10(ug/m3)‘);
ylabel(‘PM2.5(ug/m3)‘);
grid;//添加网格
axis square;//坐标轴成正方形
--------------------------------------------
pm10=[352,179,383,463,670,451,426,302,566]
pm25=[251,93,189,262,427,284,264,177,346]
plot(pm10,pm25,‘+‘);
lsline;
a=corrcoef(pm10,pm25);
s=[‘pm10‘,‘pm25‘]
title(‘PM10、PM2.5相关性分析‘);
xlabel(‘PM10(ug/m3)‘);
ylabel(‘PM2.5(ug/m3)‘);
grid;
---------------------------------------------
NOx=[141,205,183,334,444,375,248,213,322,493]
NO=[51,90,71,144,206,155,94,87,140,230]
plot(NOx,NO,‘*‘);
lsline;
a=corrcoef(NOx,NO);
str=sprintf(‘%0.5g‘,a(2));
disp(str);
text(213,140,str);
title(‘NOx、NO相关性分析‘);
xlabel(‘NOx(ug/m3)‘);
ylabel(‘NO(ug/m3)‘);
grid;
---------------------------------------
O3=[15,12,9,2,2,2,1,2,4,6]
NOx=[141,205,183,334,444,375,248,213,322,493]
a=368.09;
b=-0.219;
y=a*power(x,b);
plot(O3,NOx,‘*‘,x,y,‘r‘);
a=corrcoef(O3,NOx);
str=sprintf(‘%0.5g‘,a(2));
disp(str);
text(213,140,str);
title(‘O3、NOx相关性分析‘);
xlabel(‘O3(ug/m3)‘);
ylabel(‘NOx(ug/m3)‘);
grid;
-------------
O3=[15,12,9,2,2,2,1,2,4,6]
NOx=[141,205,183,334,444,375,248,213,322,493]
plot(O3,NOx,‘*‘);
a=368.09;
b=-0.219;
y=a*power(x,b);
plot(x,y,‘r‘);
a=corrcoef(O3,NOx);
str=sprintf(‘%0.5g‘,a(2));
disp(str);
text(213,140,str);
title(‘O3、NOx相关性分析‘);
xlabel(‘O3(ug/m3)‘);
ylabel(‘NOx(ug/m3)‘);
grid;
------------------------------------
NOx=[141,205,183,334,444,375,248,213,322,493]
NO2=[66,70,77,119,137,144,107,84,114,148]
plot(NOx,NO2,‘*‘);
lsline;
a=corrcoef(NOx,NO2);
title(‘NOx、NO2相关性分析‘);
xlabel(‘NOx(ug/m3)‘);
ylabel(‘NO2(ug/m3)‘);
grid;