1D interpolation over vector of observations with linear extrapolation

조회 수: 4 (최근 30일)
Brandon
Brandon 2022년 2월 3일
답변: Stephen23 2022년 2월 3일
I have a function, func, defined over grid. I want to evaluate this function over a vector of n observations, obs, with the ability to linearly extrapolate off grid. The obvious way to do this is to loop over n, but my goal is to avoid this because it has to be done a large amount of times.
What is an efficient alternative to the loop below?
for i=1:n
val(i) = interp1( grid, func, obs(i) ,'linear','extrap');
end

답변 (1개)

Stephen23
Stephen23 2022년 2월 3일
The query points do not have to be scalar:
interp1(grid, func, obs ,'linear','extrap')

카테고리

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