필터 지우기
필터 지우기

Column-wise interpolation of an NxM matrix?

조회 수: 13 (최근 30일)
D G
D G 2012년 7월 16일
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일
Sure:
doc interp1
  댓글 수: 4
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일
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일
A faster implementation than INTERP1: FEX: ScaleTime.

카테고리

Help CenterFile Exchange에서 Interpolation에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by