Borrar filtros
Borrar filtros

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

6 visualizaciones (últimos 30 días)
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.

Respuesta aceptada

Mrutyunjaya Hiremath
Mrutyunjaya Hiremath el 22 de Jul. de 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

Más respuestas (0)

Categorías

Más información sobre Interpolation en Help Center y File Exchange.

Productos


Versión

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by