Effacer les filtres
Effacer les filtres

How to regrid along latitude and longitude of a 3d mat file

6 vues (au cours des 30 derniers jours)
Muskula
Muskula le 22 Juil 2023
Hello people!
I have a mat file which has the dimensions of 1440x600x365 (0.25x0.25 gridded data ranging from 180° W : 180° E and 90° N : 60° S and i would like to convert to 720x360x1428. I have tried using 'interp2'to do the same but couldn't succeed.

Réponse acceptée

Mrutyunjaya Hiremath
Mrutyunjaya Hiremath le 22 Juil 2023
% Load the original data from the mat file (assuming the variable name is 'originalData')
load('your_data_file.mat', 'originalData');
% Get the size of the original data
[rows, cols, depth] = size(originalData);
% Define the desired dimensions for the new data
newRows = 720;
newCols = 360;
newDepth = 1428;
% Create the grid for the original data
[lon, lat] = meshgrid(linspace(-180, 180, cols), linspace(90, -60, rows));
% Create the grid for the new data
[newLon, newLat] = meshgrid(linspace(-180, 180, newCols), linspace(90, -60, newRows));
% Resample the original data to the new dimensions
resampledData = zeros(newRows, newCols, newDepth);
for i = 1:newDepth
resampledData(:,:,i) = interp2(lon, lat, originalData(:,:,i), newLon, newLat);
end
% Now resampledData is the new 720x360x1428 matrix that you desired
  2 commentaires
Muskula
Muskula le 24 Juil 2023
Thank you Mrutyunjaya Hiremath. It worked
Mrutyunjaya Hiremath
Mrutyunjaya Hiremath le 24 Juil 2023
Most Welcome :)

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Interpolation dans Help Center et File Exchange

Produits


Version

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by