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

1 回表示 (過去 30 日間)
Michael
Michael 2014 年 6 月 11 日
コメント済み: Michael 2014 年 6 月 11 日
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
  1 件のコメント
Michael
Michael 2014 年 6 月 11 日
I can't seem to see your answers supersyrena baklad and zcrom...

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

回答 (0 件)

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by