Filter löschen
Filter löschen

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

6 Ansichten (letzte 30 Tage)
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.

Akzeptierte Antwort

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

Weitere Antworten (0)

Kategorien

Mehr zu Interpolation finden Sie in Help Center und File Exchange

Produkte


Version

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by