# I need correct syntax of interpolation in this case

1 view (last 30 days)
BN on 5 May 2020
Commented: BN on 6 May 2020
Hello, I have a 40x32x360 double array. (latitude x longitude x time) which presents precipitation for these latitudes and longitude for 360 months.
I want to interpolate this array to found how much the precipitation value for latitude = 30.3772 and longitude 38.2147 in all 360 months (the output is 1x1x360 array).
I read about interp2 and interp3 but I don't know what is suitable in this case and how to use them. Can you tell me what is the true syntax in order to do this?

S. Walter on 5 May 2020
You'll want to make sure your latitude, longitude, and time are all 40x32x360 arrays. For that you can use ndgrid (https://www.mathworks.com/help/matlab/ref/ndgrid.html) if they are not.
In your case, you'd want something along these lines:
% Create a interpolation surface that uses latitude, longitude,
% and time to interpolate over precipitation
F = griddedInterpolant(lat,long,t,precipitation)
% Pick the time of interest
tOfInterest = [1:1:360]';
% Pick the latitude and longitude of interest but make sure
% it's the same size as your time vector
latOfInterest = 30.3772*ones(size(tOfInterest));
longOfInterest = 38.2147*ones(size(tOfInterest));
% Now interpolate to those values
Hope that helps!
BN on 6 May 2020
Dear S. Walter,
I really appreciate you, you are really helped me, Thanks.

### Categories

Find more on Interpolation in Help Center and File Exchange

R2020a

### Community Treasure Hunt

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

Start Hunting!