Azzera filtri
Azzera filtri

Cumulative distance VS time graph

18 visualizzazioni (ultimi 30 giorni)
Brendon Moore
Brendon Moore il 7 Ott 2021
Hi, I have four arrays that represent a mountain bike run, northing, easting, elevation and time all of size 2507*1, I need to find the cumulative distance of the three positional arrays in km and graph versus time. The corodinates are all in meters atm starting at origin (0,0,0) and time is in seconds starting at 0.
I belive the formula i need to use is d= sqrt((x2-x1)^2+(y2-y1)^2+(z2-z1)^2) however applying this through the three arrays from begining to end has me stuck.
Thanks for any tips
  2 Commenti
Jakob B. Nielsen
Jakob B. Nielsen il 7 Ott 2021
Can you share the code that you have so far? The formula is correct in that it is simply a generalization of the Pythagorean theorem, but if you don't show your work it is very difficult to give you pointers :)
Brendon Moore
Brendon Moore il 7 Ott 2021
Modificato: Brendon Moore il 7 Ott 2021
I will share my whole code is its part of a larger project. I made some headway and think I resolved it however a second set of eyes would be much appreciated regardless. The portion in question is function distance vs time but will run through the master code.
The whole code revolves around using low level io to import a gpx file then manipulate it in certain ways to then be able to do dynamic analysis on.

Accedi per commentare.

Risposte (1)

Walter Roberson
Walter Roberson il 7 Ott 2021
cumsum(sqrt(diff(x).^2 + diff(y).^2 + diff(z).^2))
  4 Commenti
Brendon Moore
Brendon Moore il 7 Ott 2021
Would this do the trick in its place? I tried re-writing the code and couldnt get a working result just kept throwing errors.
Thankyou for the replies btw this is super helpful. Im still very new to this.
Walter Roberson
Walter Roberson il 7 Ott 2021
Your code is equivalent to
dx = [Northing(1), diff(Northing)];
dy = [Easting(1), diff(Easting)];
dz = [Elevation(1), diff(Elevation)];
Now, suppose your entire data consists of two readings at the same location -- two different times but no movement at all. Then the diff() parts would all be 0, and you would have
dx = [Northing(1), 0];
dy = [Easting(1), 0];
dz = [Elevation(1), 0];
and you would calculate
Displacement(1) = sqrt(Northing(1)^2 + Easting(1)^2 + Elevation(1)^2)
Displacement(2) = sqrt(0^2 + 0^2 + 0^2)
and Distance(1) would be Displacement(1) and Distance(2) would be Displacement(1) + 0
is this justifiable, that the first Distance is the original coordinates? It is only if there is an implied (0,0,0) before the data and an instantaneous movement to the original coordinates (at infinite speed)
Typically it makes a lot more sense to use the initial coordinates as the base point. And in that case, you can use pure diff()

Accedi per commentare.

Community Treasure Hunt

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

Start Hunting!

Translated by