From: Lib on
Hi,

I'm new to matlab and would like to do something that I think is
pretty straight forward using interp3.

I have an array with dimensions x, y, z and I want to interpolate the
grid xy onto a finer z axis.
Then I want to extract one grid xy but it will be made up of small
parts of all the z points.
In reality z is UTC time in minutes covering 24 hours. y is the
longitude and I want a xy that corresponds to a single local time. So
for each z UTC time I search along the longitude for the local time
that I want and then extract the sliver. In the end I should get an xy
array with a common local time across the globe - if interp3 works but
it doesn't.
Here's my code:

hours = [0:3:21];
mins = [0:4.5:24*60-1];
% My initial array ciwp has dimensions x,y,z with z having the utc
times [0:3:21]
% Create a finer z that matches the longitude resolution (24*60)/320,
where 320 is the number of longitude points
[xi,yi,zi] = meshgrid(lat,lon,[0:4.5:24*60-1]);
[x,y,z] = meshgrid(lat,lon,[0:3:21]);
% Checked to see that xi, yi and zi have the right dimensions that I
require:
% x,y,z have dimensions of ciwp and xi,yi,zi have the dimensions of
the finer z axis
ZI = interp3(x,y,z,ciwp,xi,yi,zi,'linear');
% Create two array for local time 13.5 and 01.5
darr = zeros(size(ciwp,1),size(ciwp,2));
narr = zeros(size(ciwp,1),size(ciwp,2));
j = 1;
for i = mins
if (i > 60)
hr = floor(i/60);
mns = (i/60 - floor(i/60))*60;
else
hr = 0;
mns = i;
end
% Convert 1 utc to local time for all longitude points and search
for desired times
lst = mod(hr+mns/60+(0+0)/60/60+lon/15.0,24.0);
pos = abs(lst-13.5);
ind = find(pos == min(pos));
pos = abs(lst-01.5);
inn = find(pos == min(pos));
%fprintf('Hour: %d mins: %f lon: %f lst: %f ind: %d
\n',hr,mns,lon(ind),lst(ind),ind);
darr(ind,:) = ZI(ind,:,j);
narr(inn,:) = ZI(inn,:,j);
j = j + 1;
end
imagesc(darr')
*****

This image shows only a sliver and the rest 0. Further examination of
ZI revealed that interp3 didn't produce a xy array for the newer grid
zi. I don't understand why. the examples the documentation works and
this is no different except that my array is larger. But then again,
I'm new to matlab.

Any help is greatly appreciated!

/Lib