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 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