How to calculate the time of a motion
Show older comments
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 :)
Answers (3)
Thorsten
on 8 Oct 2015
0 votes
Use tic and toc.
Star Strider
on 8 Oct 2015
0 votes
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
on 8 Oct 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 Comment
Þráinn Þórarinsson
on 8 Oct 2015
Categories
Find more on Mathematics in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!