Effacer les filtres
Effacer les filtres

Interpolating 3D Gridded Data in Matlab

5 vues (au cours des 30 derniers jours)
Mark
Mark le 21 Nov 2022
Commenté : Mark le 22 Nov 2022
I have a 3D gridded data and I want to interpolate to increase the size of the data. Current resolution is 5 deg long x 5 deg latitude and I want to change the resolution to 2 deg long x 2 deg latitude as I am interested in Lat = 2 deg. The dimension of the data is (Longitude x Latitude x Height) and current size is (72x36x40).
Long= 72x36x40
Lat = 72x36x40
Height =72x36x40
Temperature =72x36x40
I tried to use the interpn function but at the end I am only getting NaN values. Below are my codes.
file='data.nc';
Lat1 = ncread(file,'Latitude'); % Size is 72x36x40
Long1 = ncread(file1, 'Longitude'); % Size is 72x36x40
Height = ncread(file1,'Height'); % Size is 72x36x40
Temp1 = ncread(file,'Temperature'); % Size is 72x36x40
[LongI,LatI,HeightI] = ndgrid(0:5:360,-90:5:90,0:10:600);
TempI = interpn(Long1,Lat1,Height,Temp1,LongI,LatI,HeightI,'linear');`
My goal is to convert 3D data at 5 long x 5 lat resolution to 2 long x 2 lat resolution.

Réponse acceptée

Matt J
Matt J le 21 Nov 2022
Modifié(e) : Matt J le 21 Nov 2022
This might be easier:
LUT= griddedInterpolant(Long1,Lat1,Height,Temp1,'linear','linear'); %create interp object
newgrid=LUT.GridVectors;
newgrid(1:2)=cellfun(@(z) z(1):2:z(end) , newgrid(1:2),'uni',0); %change the sampling lattice in the first two coordinates to be increments of 2
TempI = LUT(newgrid); %interpolate on newgrid
  11 commentaires
Matt J
Matt J le 22 Nov 2022
Modifié(e) : Matt J le 22 Nov 2022
That was given in my original answer. After the upsampling to 2 long x 2 lat, the upsampled {long,lat,height} are in newgrid, while the upsampled temperatures are in TempQ.
Mark
Mark le 22 Nov 2022
Many thanks @Matt J.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Interpolating Gridded Data dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by