how to extrapolate information from two columns?

6 ビュー (過去 30 日間)
NotGood
NotGood 2021 年 6 月 18 日
コメント済み: NotGood 2021 年 6 月 18 日
So I'm trying to extrapolate some informations from two columns at a certain time to find a postion.
A = [time ; x ; y]
hit = 4
example
[A] = [ 1, 1.5, 2, 2.75, 3.5, 6;
55, 39, 32, 28,16,10 ;
12, 19, 25, 32, 22, 14]
I know you need to sort the first row, time, to figure out which columns to use.
[~,col1] = find(A(1,:)<hit,1) %to find the column before hit
[~,col2] = find(A(1,:)>hit,1) %to find the column after hit
not sure if I'm using this, right currently stuck here. I forgot what the error was and can only access matlab at school.
but col1 should = 5 and col2 = 6
but after that, I want use a extrapolation formula to find a new x and y
using
newpostion = postion1 + ((postion2-postion1)/(time2-time1))(hit-time1)
so I get,
xnew = A(2,col1) + ((A(2,col2)-A(2,col1))/(A(1,col2)-A(1,col1)))(hit-A(1,col1))
ynew = A(3,col1) + ((A(3,col2)-A(3,col1))/(A(1,col2)-A(1,col1)))(hit-A(1,col1))
doing it by hand, I got xnew = 14.8 and ynew = 20.4

採用された回答

Jonas
Jonas 2021 年 6 月 18 日
i suggest to use the interp1() function twice, once with time and x and once with time and y. you can give the query point to each call of the interp1() function
  1 件のコメント
NotGood
NotGood 2021 年 6 月 18 日
This is a good idea, I will try it as soon as I can. I would of never know about that function.

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

その他の回答 (0 件)

カテゴリ

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

タグ

製品


リリース

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by