I want to interpolate onto different grid, how can I do this?

1 view (last 30 days)
I want to interpolate a 365 x 3127 x 254 grid onto an 365 x 84 x 180 grid. What is the best way to do this?
I think I should use interp2 (see code below) but I get the error 'Subscript indices must either be real positive integers or logicals.'. I have checked this answer but I can't seem to fix it so I ask if there is an easier way to do this?
clear
clc
load '/work/uo0122/u253082/REF.mat'
weight = cos(REF_lat);
lon = ones(180,84);
lat = ones(84,180);
lat = lat';
for yr = 1993%:2010;
yr
load(['/work/uo0122/u253082/Mat_Time/ssh_',num2str(yr),'.mat']);
ssh = ssh_int;
mask = zeros(size(ssh_int));
mask(find(ssh_int > -9E33)) = 1;
mask = repmat(mask,1,365);
ssh = ssh.*mask
for day = 1:size(ssh,1);
ssh(i,:,:) = interp2(REF_lon,REF_lat,squeeze(ssh(i,:,:)),lon,lat,'linear');
end
end
I tried getting rid of NaN's in SSH with no fix and also converting every variable to logical format with no fix. REF_lat & REF_lon = 3127 x 254 reference long and lat. SSH is a 365 x 3127 x 254 matrix and contains NaN's.
Many thanks for your attention! Michael

Answers (0)

Categories

Find more on Interpolating Gridded Data in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!