detect change of acceleration

13 views (last 30 days)
Paul Himsl
Paul Himsl on 6 Sep 2019
Answered: Star Strider on 6 Sep 2019
Hello!
I'm doing a 2D video gait analysis on a treadmill and have a problem determining the initial contact.
I know that you can detect the IC approximately with the acceleration change of the heel marker.
Can someone tell me how to find out the change of the acceleration from negative to positive from the following values (the values consist of the coordinates of the heel marker over the period of 5 gait cycles)?
The data are in the appendix
Thank you for your ideas and your time!
  6 Comments
Adam Danz
Adam Danz on 6 Sep 2019
Paul Himsl's answer moved here as a comment.
Thank you very much für your help!
Adam Danz
Adam Danz on 6 Sep 2019
happy to help (along with darova).
Let us know if you get stuck;

Sign in to comment.

Answers (1)

Star Strider
Star Strider on 6 Sep 2019
I am not certain what you want with respect to marking acceleration changes.
Try this:
D = load('data.mat');
data = double(D.data);
L = numel(data);
Ts = 1;
t = linspace(0, 1, L)*Ts; % Create Time Vector
Fs = 1/Ts;
Fn = Fs/2;
Wp = 0.200; % Passband Frequency (Normalised)
Ws = 0.350; % Stopband Frequency (Normalised)
Rp = 1; % Passband Ripple
Rs = 50; % Passband Ripple (Attenuation)
[n,Wp] = ellipord(Wp,Ws,Rp,Rs); % Order Calculation
[z,p,k] = ellip(n,Rp,Rs,Wp); % Zero-Pole-Gain
[sos,g] = zp2sos(z,p,k); % Second-Order Section For Stability
figure
freqz(sos, 2^16, Fs) % Filter Bode Plot
data_filt = filtfilt(sos, g, data); % Filter Signal
ddata_filt = gradient(data_filt); % Time Derivative
zci = @(v) find(v(:).*circshift(v(:), [-1 0]) <= 0); % Returns Approximate Zero-Crossing Indices Of Argument Vector
didx = zci(ddata_filt);
for k = 1:numel(didx)-1
idx = didx(k)-1:didx(k)+1;
tz(k) = interp1(ddata_filt(idx), t(idx), 0); % Zero-Crossing Times
dataval(k) = interp1(t(idx),data(idx), tz(k)); % ‘data’ Values At ‘tz’
end
figure
plot(t, data)
hold on
plot(t, data_filt)
plot(t, ddata_filt*25)
plot(tz, dataval, '+r', 'MarkerSize',10)
hold off
grid
legend('data','data\_filt','ddata\_filt','Inflection Points', 'Location','S')
Your data do not have much noise, although they have enough to affect the derivative calculation, so the filter appears to be necessary. Also, the inflection points do not include the last point, because that is usually difficult to determine correctly with this method.
The findpeaks function might be able to do this more efficiently, however you mentioned that you want the points where the direction changes, so I used that criterion rather than the peak values and locations.
Experiment to get the result you want.

Categories

Find more on 2-D and 3-D Plots in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!