I need correct syntax of interpolation in this case
9 views (last 30 days)
Show older comments
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?
0 Comments
Accepted Answer
S. Walter
on 5 May 2020
Behzad,
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
AnswerYouAreLookingFor = F(latOfInterest,longOfInterest,tOfInterest)
Hope that helps!
More Answers (0)
See Also
Categories
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!