interpolation in a vector

조회 수: 6 (최근 30일)
Hinna Ahmed
Hinna Ahmed 2020년 2월 5일
답변: Jyothis Gireesh 2020년 2월 11일
Hey
I have a vector like this:
v = [1 24 56 87 98 45 67 89 34 56]
and my time axis;
t = [1 2 3 4 5 6 7 8 9 10]
If a want to interpolate the value at time point t=9, how can I do that?
Thanks in advance
  댓글 수: 4
Adam
Adam 2020년 2월 5일
편집: Adam 2020년 2월 5일
Interpolated based on what? Linear interpolation?
t(9) = mean( t( [8 10] ) );
would do that.
Sindar
Sindar 2020년 2월 5일
interp1

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

채택된 답변

Jyothis Gireesh
Jyothis Gireesh 2020년 2월 11일
I am assuming here that you want to replace the sample corresponding to t=9 using linear interpolation. The following line of code may be helpful in solving this.
newValue = interp1([1:8 10], [v(1:8) v(10)], 9);
It is also possible to change the interpolation technique by specifying it as an additional input argument. For instance, if ‘pchip’
technique is to be used,
newValue = interp1([1:8 10], [v(1:8) v(10)], 9, 'pchip');
Please refer to the following documentation link on “interp1()” for any further clarifications
Hope this helps!!

추가 답변 (0개)

카테고리

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