interpolate 3 dimensional arrays (in time and space)

Hi all,
I have 3D matrix 180x90x120 which is equal to lonxlatxtime. In space, the data has 1 degree resolution (e.g. longitude ranges from 1 to 180), while the time interval is 3 hours (e.g. 3h, 6h, 9h.....).
Now I want to interpolate data to get a finer resolution of 0.5 degree and with 1-hour interval, so the new matrix would be 360x180x360.
Could you please help?
Thanks

4 Comments

Hi, I see I can use griddata to interpolate in spatial space, so now my concern is only how to interpolate data in time. Lets simplify, assuming I have 2 dimensional matrices at 1:00AM A1=[1 1; 1 1], at 2:00AM A2=[2 2; 2 2], at 3:00AM A3= [3 3; 3 3] what I need to do, for instance, to get additional data at 1:30AM it should be A1.5 = [1.5 1.5; 1.5 1.5] and at 2:30AM A2.5 = [2.5 2.5; 2.5 2.5]. To this end, I will have data at 1:00 AM, 1:30AM; 2:30AM; 3:00AM...etc.
I believe it could be simple for many of you, but I am still stuck in it. Could you please help.
Thanks
Matt J
Matt J on 28 Aug 2018
Edited: Matt J on 28 Aug 2018
No, do not use griddata for this. KL's suggestion of griddedInterpolant was appropriate. See also my second answer.
Matt J
Matt J on 28 Aug 2018
Edited: Matt J on 28 Aug 2018
Now I want to interpolate data to get a finer resolution of 0.5 degree and with 1-hour interval, so the new matrix would be 360x180x360.
Those will not be the new dimensions. If you sample from 1 to 180 at intervals of 0.5, you will obtain 359 points, not 360. Similarly for the other dimensions.

Sign in to comment.

 Accepted Answer

Matt J
Matt J on 28 Aug 2018
Edited: Matt J on 28 Aug 2018
F=griddedInterpolant(yourData);
qlon=(1:.5:180);
qlat=(1:.5:90);
qtime=(1:1/3:120);
newData=F({qlon,qlat,qtime});

2 Comments

THIS WORKS FOR ME!!!!!!!! THANKS MATT
Dear Matt J,
Sorry. It works but the outcomes are not as I expected. Particularly the new results look weird. Perhaps I also misunderstood about the input matrix format. To be corrected, the 3D matrices I mentioned, for instance, 180x90x120 contains 120 2D arrays size (180x90) for monthly wind speeds in Longitude and Latitude direction. These 120 matrices correspond to a 1D time matrix (which is separated): 0h 6h 12h 18h.....720h..
So when I use:
v = winddata % (size: 180x90x120)
F= griddedInterpolant(v)
qlon=(1:.5:180)
qlat=(1:.5:90);
qtime=(1:1/3:120);
newwinddata=F({qlon,qlat,qtime});
it does not work properly because time does not present in griddedInterpolant(v).
May you help more? Thanks

Sign in to comment.

More Answers (1)

Matt J
Matt J on 28 Aug 2018
Edited: Matt J on 28 Aug 2018
You could download IMRESIZEN, and then do things like,
>> A=rand(180,90,120); B=imresizen(A,[2,2,3]); whos B
Name Size Kilobytes Class Attributes
B 360x180x360 182250 double

2 Comments

Thanks Matt, but it does not for my situation because Imresizen just scales up the data.
Has anyone done something similar to this? May you help?
Thanks
How is that different from what you are trying to do?

Sign in to comment.

Categories

Find more on Interpolation in Help Center and File Exchange

Asked:

on 28 Aug 2018

Commented:

on 29 Aug 2018

Community Treasure Hunt

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

Start Hunting!