フィルターのクリア

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

6 ビュー (過去 30 日間)
Muskula
Muskula 2023 年 7 月 22 日
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
  2 件のコメント
Muskula
Muskula 2023 年 7 月 24 日
Thank you Mrutyunjaya Hiremath. It worked
Mrutyunjaya Hiremath
Mrutyunjaya Hiremath 2023 年 7 月 24 日
Most Welcome :)

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeInterpolation についてさらに検索

製品


リリース

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by