how to extrapolate information from two columns?

6 vues (au cours des 30 derniers jours)
NotGood
NotGood le 18 Juin 2021
Commenté : NotGood le 18 Juin 2021
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

Réponse acceptée

Jonas
Jonas le 18 Juin 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
  1 commentaire
NotGood
NotGood le 18 Juin 2021
This is a good idea, I will try it as soon as I can. I would of never know about that function.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur MATLAB dans Help Center et File Exchange

Produits


Version

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by