필터 지우기
필터 지우기

How to find the coefficient of determination (R2) between 2 variables in netcdf?

조회 수: 3 (최근 30일)
I have attached a zipped netcdf file ('ssh.nc').
I wanted to do a corellation test (OR to find the R2 value between two variables). The two variables are 'zos' and 'bottomT' which have the following dimensions of longitude,latitude,time. After this I wanted to plot a map so I can find out in which regions the correlation is high/low.
I tried to use ncread and extract grid-by-grid values but it is time- consuming and I might be prone to making errors. Is there any code that can find the correlation between two variables?
Would be grateful for assistance in this.

답변 (1개)

KSSV
KSSV 2018년 12월 4일
It depends whether you want to find it spatially or temporally. I feel temporal regression is the one you are looking for. Check this code:
ncfile = 'ssh.nc' ;
A = ncread(ncfile,'zos') ;
B = ncread(ncfile,'bottomT') ;
[nx,ny,nt] = size(A) ;
R = zeros(nx,ny) ;
for i = 1:nx
for j = 1:ny
Ai = squeeze(A(i,j,:)) ;
Bi = squeeze(B(i,j,:)) ;
R(i,j) = regression(Ai',Bi')^2 ;
end
end
  댓글 수: 1
Keegan Carvalho
Keegan Carvalho 2018년 12월 4일
편집: Keegan Carvalho 2018년 12월 4일
Thanks KSSV, but I wanted to find it spatially.
Btw, I tried the above code but unfortunately did not suceed since I didn't have the Deep Learning Toolbox.
However, I would like to know how to do it spatially.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 NetCDF에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by