How to plot regression coefficients on a map?
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Keegan Carvalho
am 20 Dez. 2018
Kommentiert: Aristo Pacino
am 20 Jul. 2021
I have attached a zipped netcdf file ('ssh.nc'). I wanted to do a corellation test between variables, 'zos' and 'bottomT' which have the following dimensions of longitude,latitude,time. After this I wanted to plot the correlation coefficients on a map.
I tried the following code but get an error about the rows. I find it weird since the dimensions are the same.
>> lat = ncread('ssh.nc','latitude');
>> lon = ncread('ssh.nc','longitude');
>> ssh = ncread('ssh.nc','zos');
>> t = ncread('ssh.nc','bottomT');
>> nx=length(lon);
>> ny=length(lat);
>> for i=1:nx
for j=1:ny
[r,s] = corr(t,ssh(i,j,:));
rxy(i,j)=r;
sxy(i,j)=s;
end
end
I get the error:
Error using corr (line 106)
X and Y must have the same number of rows.
I also tried correlate, corr2 but get errors.
Would be grateful to receive help in this, preferably with the correct codes, since I am going wrong somehere. I also want to know what's wrong in the above.
0 Kommentare
Akzeptierte Antwort
KSSV
am 20 Dez. 2018
Bearbeitet: KSSV
am 20 Dez. 2018
YOu need to calculate the coeffecenits for 3D matrix.
lat = ncread('ssh.nc','latitude');
lon = ncread('ssh.nc','longitude');
ssh = ncread('ssh.nc','zos');
t = ncread('ssh.nc','bottomT');
nx=length(lon);
ny=length(lat);
rxy = zeros(nx,ny) ;
sxy = zeros(nx,ny) ;
for i=1:nx
for j=1:ny
[r,s] = corr(squeeze(t(i,j,:)),squeeze(ssh(i,j,:)));
rxy(i,j)=r;
sxy(i,j)=s;
end
end
7 Kommentare
Aristo Pacino
am 20 Jul. 2021
Hi, @KSSV, I have used the same code for calculating correlation coefficient at grid points using the above code but I am getting NaN values. Please find attached data.
Some specification:
- Lat =0:10:360
- Lon = -180:10:180
- t and ssh are 37-by-37 matrix
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Annotations finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!