필터 지우기
필터 지우기

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

조회 수: 6 (최근 30일)
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.

채택된 답변

Mrutyunjaya Hiremath
Mrutyunjaya Hiremath 2023년 7월 22일
% 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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Interpolation에 대해 자세히 알아보기

제품


릴리스

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by