load ~/NC/grid
load /Users/yangyang/Aerosol_Variaiton/ERUN/SSLT/ncfile/SSLT_monthly.mat
load /Users/yangyang/Aerosol_Variaiton/ERUN/UWND/ncfile/UWND_monthly.mat
load /Users/yangyang/Aerosol_Variaiton/ERUN/PRECT/ncfile/PRECT_monthly.mat

corr_UWND=zeros(144,96);
corr_PRECT=zeros(144,96);

for i=1:144
    for j=1:96
        temp=corrcoef(SSLT_MONTH(i,j,:),UWND_MONTH(i,j,:));
        corr_UWND(i,j)=temp(1,2);
        temp=corrcoef(SSLT_MONTH(i,j,:),PRECT_MONTH(i,j,:));
        corr_PRECT(i,j)=temp(1,2);
    end
end



save('SSLT_CORR.mat','corr_UWND','corr_PRECT')

nccreate('SSLT_CORR.nc','lat','Dimensions',{'lat',96},'Format','classic')
ncwrite('SSLT_CORR.nc','lat', lat)
ncwriteatt('SSLT_CORR.nc','lat','units','degrees_north')
ncwriteatt('SSLT_CORR.nc','lat','long_name','Latitude')
nccreate('SSLT_CORR.nc','lon','Dimensions',{'lon',144},'Format','classic')
ncwrite('SSLT_CORR.nc','lon', lon)
ncwriteatt('SSLT_CORR.nc','lon','units','degrees_east')
ncwriteatt('SSLT_CORR.nc','lon','long_name','Longitude')
nccreate('SSLT_CORR.nc','corr_UWND','Dimensions',{'lon',144,'lat',96},'Format','classic')
ncwrite('SSLT_CORR.nc','corr_UWND', corr_UWND)
nccreate('SSLT_CORR.nc','corr_PRECT','Dimensions',{'lon',144,'lat',96},'Format','classic')
ncwrite('SSLT_CORR.nc','corr_PRECT', corr_PRECT)
ncdisp('SSLT_CORR.nc')