How to perform an interpolation for Cartesian coordinates?

Hi everybody, I am working on a table containing Cartesian coordinates (X,Y,Z). These coordinates represents the trajectory of a vehicle. The measurement rate is 12 measurements per minute (one measurement every 5 seconds). I would like to perform an interpolation in such a way that I get one measurement per second. I have tried to use "interp3" and "griddedInterpolant" but frankly the syntax is quite complex for a beginner. If someone takes the time to help me, I would be grateful. Best regards !!!

 Respuesta aceptada

Let's say TIME,X,Y,Z are your measurements at a distance of 5 sec for TIME.

Let's build a new time vector

TIME_REQUESTED = TIME(1):TIME(end) 

at a distance of 1 sec.

Then you get your 1 sec vectors X_REQUESTED, Y_REQUESTED and Z_REQUESTED simply by

X_REQUESTED = interp1(TIME,X,TIME_REQUESTED);
Y_REQUESTED = interp1(TIME,Y,TIME_REQUESTED);
Z_REQUESTED = interp1(TIME,Z,TIME_REQUESTED);

Best wishes

Torsten.

3 comentarios

First, Torsten let me thank for your help. This worked perfectly. Actually, it didn't come to my mind to interpolate every dimension aside. I thought that the result should be different. If you may excuse me, I have one more question. In this example, we are dealing with a constant distance of time (5 seconds for instance). What if the initial measurements weren't equally distanced. How to perform the interpolation ? Thanks again for your time.
Just in the same way as above.
got it. Thanks for your time.

Iniciar sesión para comentar.

Más respuestas (1)

KSSV
KSSV el 18 de Abr. de 2018
t = 0:5:2*60 ;
N = length(t) ;
x = cos(t) ;
y = sin(t) ;
z = 2*t ;
plot3(x,y,z)
% Do inteprolation 
ti = min(t):1:max(t) ;
xi = interp1(t,x,ti) ;
yi = interp1(t,y,ti) ;
zi = interp1(t,z,ti) ;
hold on
plot3(xi,yi,zi,'.r')

4 comentarios

Thank you for taking the time to answer me. However, I don't see the use of the variable "N". Moreover, I can't see why you defined
t = 0:5:2*60
KSSV
KSSV el 18 de Abr. de 2018
I have given a pseudo code.....so that by understanding this..you can code your case.
MOHAMED BEN STA
MOHAMED BEN STA el 18 de Abr. de 2018
Editada: MOHAMED BEN STA el 18 de Abr. de 2018
Thank you for your help. I really appreciate.
KSSV
KSSV el 18 de Abr. de 2018
Thanking is accepting or voting the answer..:)

Iniciar sesión para comentar.

Categorías

Más información sobre Interpolation en Centro de ayuda y File Exchange.

Preguntada:

el 18 de Abr. de 2018

Comentada:

el 20 de Abr. de 2018

Community Treasure Hunt

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

Start Hunting!

Translated by