How to find the coefficient of determination (R2) between 2 variables in netcdf?
2 ビュー (過去 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.
0 件のコメント
回答 (1 件)
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
参考
カテゴリ
Help Center および File Exchange で NetCDF についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!