필터 지우기
필터 지우기

Fast linear matrix interpolation for time data NOT equally spaced

조회 수: 1 (최근 30일)
Spigge
Spigge 2013년 8월 15일
I desperately need a fast linear matrix interpolation function for NOT equally spaced time data. Matlab's interp1 is slow and your contribution ScaleTime, albeit very fast, only accepts equally spaced time data (right?). Any suggestions?
Thanks,
Fredrik

채택된 답변

Jan
Jan 2013년 8월 15일
편집: Jan 2013년 8월 15일
I assume, you mean FEX: ScaleTime. The new version is still in the pipeline. But this works efficiently for not equally spaced data as long as X is sorted:
function Yi = myLinearInterp(X, Y, Xi)
% X and Xi are column vectors, Y a matrix with data along the columns
[dummy, Bin] = histc(Xi, X); %#ok<ASGLU>
H = diff(X); % Original step size
% Extra treatment if last element is on the boundary:
sizeY = size(Y);
if Bin(length(Bin)) >= sizeY(1)
Bin(length(Bin)) = sizeY(1) - 1;
end
Xj = Bin + (Xi - X(Bin)) ./ H(Bin);
Yi = ScaleTime(Y, Xj);
A full M-version can be found here.
  댓글 수: 1
Spigge
Spigge 2013년 8월 16일
It works great, 5 x faster than interp1 using my matrix data. This means I can do the calculations I need without reducing the framerate in my application. Many thanks!
Fredrik

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by