Could someone explain me this code?
meas.jerk.time = (meas.acc.time(1:end-1) + meas.acc.time(2:end)) ./ 2;
Assuming that meas.acc.data and meas.acc.time are vectors with the same number of elements, then diff on the data vector will return a numeric vector with one element fewer than the time vector, so meas.jerk.data and meas.jerk.time will likely have mismatching sizes.
But idk the syntax of this code. What does (1:end-1) mean or (2:end) ./2?
Matlab has a lot of array indexing tools. If
vis a vector, thenv(1:end-1)gives you the first through the second last elements ofv, andv(2:end)gives the second through the last elements.For more information on this, see the help page: https://www.mathworks.com/company/newsletters/articles/matrix-indexing-in-matlab.html.
Furthermore, the
./operator stands for "element-wise right division" --, sov ./ 2will divide every element ofvby 2.