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

Illustration
Muskula - 2023-07-24T14:51:55+00:00
Question: How to regrid along latitude and longitude of a 3d mat file

Hello!   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.

Expert Answer

Profile picture of Prashant Kumar Prashant Kumar answered . 2025-11-20

Hello! Regridding along latitude and longitude in a 3D matrix can be challenging, but it is achievable. Here's a step-by-step approach to regrid your data from a 1440x600x365 matrix to a 720x360x1428 matrix using MATLAB:

1. Load your data: 
   First, load the data from your .mat file.

    data = load('yourfile.mat');
    % Assume the variable name in the file is 'data'
    

2. Create original and target grids:
   Define the original and target grid coordinates.

    
    [lon_orig, lat_orig, time_orig] = ndgrid(linspace(-180, 180, 1440), linspace(60, -90, 600), 1:365);
    [lon_new, lat_new, time_new] = ndgrid(linspace(-180, 180, 720), linspace(60, -90, 360), linspace(1, 365, 1428));
   

3. Interpolate data: 
   Use `interp3` to interpolate the data to the new grid.

    
    data_new = interp3(lon_orig, lat_orig, time_orig, data.data, lon_new, lat_new, time_new, 'linear');
    

4. Save the new data:
   Save the regridded data into a new .mat file.

    save('newfile.mat', 'data_new');
    

This should give you the regridded data on the desired 720x360x1428 grid.

 

 


Not satisfied with the answer ?? ASK NOW

Get a Free Consultation or a Sample Assignment Review!