How to calculate velocity from X and Y positions and time?
37 ビュー (過去 30 日間)
古いコメントを表示
What would be the best/most correct way of calculating velocity (total velocity, not X and Y components of velocity) from the following X and Y positions at the given timepoints? Not sure whether (and exactly how) to use a diff or a gradient function... Also, how could I get a one dimension position value, for the purpose of calculating STD at the given timepoints for several of these datasets?
Table =
20×3 table
Time PosX PosY
_______ ______ ______
0 363.79 255.3
0.00833 352.32 252.27
0.01666 342.07 236.94
0.02499 320.48 225.84
0.03332 287.69 209.97
0.04165 272.58 197.78
0.04998 261.67 193.81
0.05831 261.72 205.85
0.06664 269.66 224.84
0.07497 283.41 250.91
0.0833 290.57 250.67
0.09163 292.02 250.13
0.09996 296.21 251.24
0.10829 298.06 252.43
0.11662 306.25 265.04
0.12495 320.4 286
0.13328 334.88 315.34
0.14161 346.22 333.17
0.14994 357.84 336.76
0.15827 366.17 333.72
0 件のコメント
採用された回答
Torsten
2022 年 3 月 27 日
for the purpose of calculating STD at the given timepoints for several of these datasets?
STD of what ?
8 件のコメント
Torsten
2022 年 3 月 27 日
編集済み: Torsten
2022 年 3 月 28 日
Since we don't know better, we assume the shortest distance between two points.
This gives:
M=[0 363.79 255.3
0.00833 352.32 252.27
0.01666 342.07 236.94
0.02499 320.48 225.84
0.03332 287.69 209.97
0.04165 272.58 197.78
0.04998 261.67 193.81
0.05831 261.72 205.85
0.06664 269.66 224.84
0.07497 283.41 250.91
0.0833 290.57 250.67
0.09163 292.02 250.13
0.09996 296.21 251.24
0.10829 298.06 252.43
0.11662 306.25 265.04
0.12495 320.4 286
0.13328 334.88 315.34
0.14161 346.22 333.17
0.14994 357.84 336.76
0.15827 366.17 333.72];
dt = M(2:size(M,1),1)-M(1:size(M,1)-1,1);
dx = M(2:size(M,1),2)-M(1:size(M,1)-1,2);
dy = M(2:size(M,1),3)-M(1:size(M,1)-1,3);
dist = sqrt(dx.^2+dy.^2);
vel = dist./dt;
velx = abs(dx)./dt;
vely = abs(dy)./dt;
plot((M(1:size(M,1)-1,1)+M(2:size(M,1),1))/2,vel,'color','b') % absolute velocity
%plot((M(1:size(M,1)-1,1)+M(2:size(M,1),1))/2,sqrt(velx.^2+vely.^2),'color','g') % also absolute velocity for checking
hold on
plot((M(1:size(M,1)-1,1)+M(2:size(M,1),1))/2,velx,'color','r') % x velocity
hold on
plot((M(1:size(M,1)-1,1)+M(2:size(M,1),1))/2,vely,'color','y') % y-velocity
hold off
vel(i) is the average absolute velocity between time instant t_i and t_i+1 if we assume that the movement is on the straight line between (x(i),y(i)) and (x(i+1),y(i+1)) (1<=i <=19).
Note that the velocity arrays have one element less than the position arrays.
You may think of vel not as velocities in points, but over intervals (here: vel(i) as velocity over the interval [t_i,t_i+1)).
その他の回答 (1 件)
Sam Chak
2022 年 3 月 27 日
First, you need to obtain the distances
between each point specified by the coordinates.


Then, I think you compute the velocity with this formula:

4 件のコメント
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!