How do I calculate the acceleration using only 3D distances?

7 ビュー (過去 30 日間)
lil brain
lil brain 2022 年 4 月 15 日
コメント済み: Les Beckham 2022 年 4 月 18 日
Hi,
I have a list of distances in each cell of acc_dist . The first three columns in each cell are xyz coordinates. So column one are all x, column two are all y, and column three are all z. The rows are the coordinate points measured at a speed of 72 Hz.
I am trying to compute the acceleration of these coordinate points by first calculating the 3D euclidean distance between each point and the adjacent point like so:
sqrt((x2-x1).^2+(y2-y1).^2+(z2-z1).^2)
And then I am trying to use the acceleration formula like so:
acceleration = dv/dt
dv = change in velocity
dt = change in time
How would I go about calculating the acceleration for the entire length of each list?
Thank you!
  4 件のコメント
Walter Roberson
Walter Roberson 2022 年 4 月 15 日
Use gradient() twice.
However... acceleration is a signed vector quantity, derived from velocity which is a signed vector quantity. This is a problem for you because sqrt((x2-x1).^2+(y2-y1).^2+(z2-z1).^2) is not signed and not a vector. You are calculating speed, not velocity.
lil brain
lil brain 2022 年 4 月 15 日
編集済み: lil brain 2022 年 4 月 15 日
@Walter Roberson I dont think I follow could you elaborate on that?

サインインしてコメントする。

採用された回答

Les Beckham
Les Beckham 2022 年 4 月 15 日
編集済み: Les Beckham 2022 年 4 月 15 日
load acc_dist.mat
xyz = cell_of_double_pre_ballsCopy{1};
dxyz = diff(xyz); % difference between adjacent points in xyz coordinates
v = sqrt(dxyz(:,1).^2 + dxyz(:,2).^2 + dxyz(:,3).^2) * 72;
a = gradient(v, 1/72);
t = 0:1/72:(length(a)-1)/72;
plot(t,v)
plot(t,a)
  13 件のコメント
Walter Roberson
Walter Roberson 2022 年 4 月 17 日
"Apply this function to every element of this array" is one of the fundamental array operations in theory.
Consider for example,
A = [1 3 5]
A = 1×3
1 3 5
B = A.^2
B = 1×3
1 9 25
From a theoretical perspective, this is not "squaring the vector": from a theoretical perspective, it is "Apply the function x->x^2 to each element of A, returning an array of the results.
This is frequenty called the "map" operation. And having a brief call that says that you are mapping a function over all of the elements of an array, is often significantly clearer than using a for loop.
Les Beckham
Les Beckham 2022 年 4 月 18 日
Point taken. Thanks for clarifying.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeResizing and Reshaping Matrices についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by