Column-wise interpolation of an NxM matrix?

Hi!
I'm wondering if it is possible to interpolate column-wise along an NxM matrix.
Previous size were:
x = 1x200
Y = 1x200
xi = 1x200
New values are
x = 1x200
Y = 10x200
xi = 1x200
I have a loop that does it now, but would prefer to vectorize it as long as it is readable.
Thanks!

1 件のコメント

Jan
Jan 2012 年 7 月 16 日
How do you "interpolate" along a singelton dimension? Could post your loop method - by editing the question, not as comment or answer?

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

回答 (3 件)

Sean de Wolski
Sean de Wolski 2012 年 7 月 16 日

0 投票

Sure:
doc interp1

4 件のコメント

D G
D G 2012 年 7 月 16 日
編集済み: D G 2012 年 7 月 16 日
No, It doesn't work. It gives an error in the griddedInterpolant function.
The size of the grid point arrays should match the size of the
value arrays.
Error in interp1>LinearShiftBounds (line 255)
F = griddedInterpolant(X,V(:,1));
Error in interp1 (line 216)
[X, V] = LinearShiftBounds(X, V, Xq);
Sean de Wolski
Sean de Wolski 2012 年 7 月 16 日
It works just fine...
y = magic(10);
x = (1:10)';
xi = linspace(1,10,50)';
interp1(x,y,xi)
D G
D G 2012 年 7 月 16 日
Try this:
y = magic(10);
x = (1:20)';
xi = linspace(1,10,50)';
interp1(x,y,xi, 'linear', 'extrap');
Why would this fail?
Teja Muppirala
Teja Muppirala 2012 年 7 月 17 日
That fails because y has 10 values, and your x has 20 values. But as Sean said, INTERP1 works perfectly fine. Just transpose your data first:
Yi = interp1(x',Y',xi','linear','extrap')';

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

Doug Hull
Doug Hull 2012 年 7 月 16 日

0 投票

Why do you want to vectorize it?
If it is working, and it is apparently readable, wouldn't your time be better spent on other aspects of the code?

1 件のコメント

D G
D G 2012 年 7 月 16 日
The code has a lot of repetitions in our calculations.

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

Jan
Jan 2012 年 7 月 16 日

0 投票

A faster implementation than INTERP1: FEX: ScaleTime.

カテゴリ

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

質問済み:

D G
2012 年 7 月 16 日

Community Treasure Hunt

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

Start Hunting!

Translated by