Find value in interpolated data

65 ビュー (過去 30 日間)
Jan Wingens
Jan Wingens 2015 年 11 月 17 日
コメント済み: Can 2021 年 11 月 25 日
Assume I have a vector of data y(nx1) which correspond to a time vector t(nx1).
What I need is some way to find a certain value of y for an arbitrary point of time. Lets say t covers a timespan of 0 to 10 seconds. I want to get the corresponding value of y for t=2.334.
Now if there is a t=2.334 exactly in the time vector I could find the corresponding entry in y. But if one entry reads t=2.1 and the next t=2.5 I don't have a corresponding value.
I would like to interpolate y so that I can find a value for any given time.
However I am fairly new to Matlab. Could someone tell me how to do this the best way?

採用された回答

Chad Greene
Chad Greene 2015 年 11 月 17 日
Use interp1. It's exactly what you need
yi = interp1(t,y,2.2334);
  3 件のコメント
Shubham Wakchaure
Shubham Wakchaure 2021 年 5 月 11 日
@Chad Greene How to do it for the 3d case ?
Can
Can 2021 年 11 月 25 日
@Shubham Wakchaure With interp3 of course.

サインインしてコメントする。

その他の回答 (1 件)

Kirby Fears
Kirby Fears 2015 年 11 月 17 日
Check out the interp1 function as well as the spline function.
For your example, you can find the value for t=2.334 given t and y using linear interpolation with interp1:
myval = interp1(t,y,2.334);
Hope this helps.
  1 件のコメント
Jan Wingens
Jan Wingens 2015 年 11 月 18 日
Thanks

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeInterpolation についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by