How can i calculate the velocity of al those rats in X and Y coordinates
Show older comments
Hey Guys,
I have a file with time and many X and Y coordinates of 8 rats who walk through a maze, i need to calculate the X and Y velocity of al those rats separately. Can someone help me with this? (Sorry i am a matlab noob...)
Answers (1)
Sean de Wolski
on 20 Mar 2014
To get the data into MATLAB, use the Import Tool on the left hand side of the toolstrip or double click the file in the current folder browser.
At each step, calculate the distance walked by each rat (I'd use hypot and diff to do this) and divide by the time.
For example:
x = 0:10
y = 0:10
t = 0:10
rates = hypot(diff(x),diff(y))./diff(t)
% hypot(Difference in x difference in y) divided by difference in t
Categories
Find more on Labyrinth problems in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!