how to extrapolate information from two columns?

6 次查看(过去 30 天)
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 CenterFile Exchange 中查找有关 MATLAB 的更多信息

标签

产品


版本

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by