How to Interpolate *between* 2D matrices

I think this is an easy question, but my attempts so far have been frustrated. I have a series of 2D (1300x1500) regularly spaced matrices (basically change over time). I want to interpolate between these to create additional 2D matrices that will be intermediates between the others. I am sure that griddata3 should be able to do this, but I can't get it to work.

2 件のコメント

Jos (10584)
Jos (10584) 2014 年 2 月 12 日
Assume you have two very simple 2D matrices that make up the series
A1 = [2 0 0]
A3 = [0 0 2]
What should an intermediate matrix, A2, look like?
[1 0 1]
[0 2 0]
??
Mahi Nazir
Mahi Nazir 2014 年 2 月 12 日
Hi Jos This question has been answered.. The new question is in my comment below

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

 採用された回答

the cyclist
the cyclist 2011 年 1 月 31 日

5 投票

Are you only doing interpolation along the time dimension? I think you should be able to use interp1.
Assuming you have N time slices, then you can first concatenate the arrays you have, then permute (because interp1 has to have interpolated dimension first), then interpolate:
% Your 2D arrays:
x1 = [1 2; 3 4];
x2 = [2 3; 4 5];
% Concatenate:
x = cat(3,x1,x2);
% Permute to get interpolated dimension first:
x = permute(x,[3 1 2])
% Define arbitrary unit for time slices:
t0 = [1 2];
% Interpolate to time slice at t=1.5:
x_interp = interp1(t0,x,1.5)
I see that your input 2D arrays are quite large, so you may need to do this in chunks.
[griddata3 is a deprecated function, and you probably don't want to use it.]

3 件のコメント

Warren
Warren 2011 年 1 月 31 日
Success. Looks like you nailed it - I am indeed only doing a 1D interp (e.g. Time, but not changing the original 2D matrices or their resolution). I wouldn't have thought of it that way. I only have to do this once (hopefully) so doing it in chunks isn't a problem. Thanks a lot.
Mahi Nazir
Mahi Nazir 2014 年 2 月 12 日
編集済み: Mahi Nazir 2014 年 2 月 12 日
Hi I am also looking for interpolation between 4 matrices but my matrices change along the coordinates (x,y) and NOT along just one dimension t.... Do I need to use interp2? I have to use 4 way interpolation? Kindly help.
Thanks
the cyclist
the cyclist 2014 年 2 月 12 日
I strongly suggest you open a new question, not bury it within a comment of a 3-year-old, already-answered question, where very few people will see it. (It was a random stroke of luck that I happened to notice this.)

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeInterpolation についてさらに検索

質問済み:

2011 年 1 月 31 日

コメント済み:

2014 年 2 月 12 日

Community Treasure Hunt

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

Start Hunting!

Translated by