interpolation in a vector

3 Ansichten (letzte 30 Tage)
Hinna Ahmed
Hinna Ahmed am 5 Feb. 2020
Beantwortet: Jyothis Gireesh am 11 Feb. 2020
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 Kommentare
Adam
Adam am 5 Feb. 2020
Bearbeitet: Adam am 5 Feb. 2020
Interpolated based on what? Linear interpolation?
t(9) = mean( t( [8 10] ) );
would do that.
Sindar
Sindar am 5 Feb. 2020
interp1

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Jyothis Gireesh
Jyothis Gireesh am 11 Feb. 2020
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!!

Weitere Antworten (0)

Kategorien

Mehr zu Interpolation finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by