How to calculate the time of a motion
Mostrar comentarios más antiguos
I am working on a project where the cursor on a computer screen moves on a certain path. I have three vectors: x-coordinate, y-coordinate and velocity in each point. Now I need to calculate the time it takes the cursor to finish the path and I have no idea how.
Any help much appreciated.
Thanks :)
Respuestas (3)
Thorsten
el 8 de Oct. de 2015
0 votos
Use tic and toc.
Star Strider
el 8 de Oct. de 2015
0 votos
I don’t have your data, but if you have the distance and velocity at each point, finding the time seems straightforward. Am I missing something in the description of your problem?
Torsten
el 8 de Oct. de 2015
If you have a parametrization of your path of the form x=x(s),y=y(s) with (x(0),y(0))=startpoint and (x(1),y(1))=endpoint, then
T=integral_{s=0}^{s=1} sqrt((dx/ds)^2+(dy/ds)^2)/u(x(s),y(s)) ds
where u(x(s),y(s)) is the velocity magnitude in the point (x(s),y(s)).
Otherwise, you can approximate the time as a finite sum:
T=sum_{i=1}^{i=N-1} sqrt((x(i+1)-x(i))^2+(y(i+1)-y(i))^2)/(0.5*(u(x(i),y(i))+u(x(i+1),y(i+1))))
Best wishes
Torsten.
1 comentario
Þráinn Þórarinsson
el 8 de Oct. de 2015
Categorías
Más información sobre Mathematics en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!