Skip to main content

calcStepLength.m


% This function is part of the NMSM Pipeline, see file for full license.
%
% This function calculates the step length for the specified foot for one
% gait cycle.
%
% (Array of number, Array of number) -> (Number)
%


function stepLength = calcStepLength(normalForce, heelPosition)

normalForce = normalForce - 30; % Noise buffer
normalForce(normalForce<0) = 0;
slope = diff(normalForce);
heelStrikeEvent = getHeelStrikeEvent(slope);
if isempty(heelStrikeEvent)
if normalForce(1) == 0
heelStrikeEvent = 1;
stepLength = heelPosition(heelStrikeEvent, 1) - ...
heelPosition(heelStrikeEvent, 2);
else
stepLength = 0;
end
else
stepLength = heelPosition(heelStrikeEvent, 1) - ...
heelPosition(heelStrikeEvent, 2);
end
end