필터 지우기
필터 지우기

Speed up 1D spline interpolation on matrix

조회 수: 1 (최근 30일)
T
T 2017년 9월 13일
편집: Matt J 2017년 9월 14일
Hello,
I have a NxM matrix named data and I need to spline interpolate each row of my matrix according to:
for k=1:size(data,1)
data(k,:)=spline( x , data(k,:).', x + shift(k,:).' );
end
where x is the original monotonously increasing spacing of each row. And the NxM matrix shift is the row- and column-dependent shift that I want to apply to each sample.
Is there a way to speed this up further? I found a lot of functions that claim a speed improvement of x10 for linear interpolation. Anything I can do for spline?
Thanks!

답변 (1개)

Matt J
Matt J 2017년 9월 13일
편집: Matt J 2017년 9월 14일
It might help to pose it as a 2D interpolation,
[m,n]=size(data);
idx=1:n;
F=griddedInterpolant({x,idx},data,'cubic');
uu= x+shift.';
vv=repmat(idx,m,1);
data=reshape( F([uu(:),vv(:)]), m,n) ;

카테고리

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