how to extrapolate information from two columns?
6 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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
0 Kommentare
Akzeptierte Antwort
Jonas
am 18 Jun. 2021
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
Weitere Antworten (0)
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!