Skip to main content

calcFootMarkerPositionAndSlopeError.m


% This function is part of the NMSM Pipeline, see file for full license.
%
% Calculate error between experimental and modeled foot marker positions.
% This function returns position and velocity errors.
%
% (struct, struct) -> (Array of double, Array of double)
% Calculate error between experimental and modeled foot marker positions.


function [valueError, slopeError] = ...
calcFootMarkerPositionAndSlopeError(task, modeledValues)
markerFieldNames = fieldnames(task.markerNames);
valueError = [];
slopeError = [];
for i=1:length(markerFieldNames)
newValues = abs(task.experimentalMarkerPositions. ...
(markerFieldNames{i}) - modeledValues.markerPositions. ...
(markerFieldNames{i}));
newSlope = abs(task.experimentalMarkerVelocities. ...
(markerFieldNames{i}) - modeledValues.markerVelocities. ...
(markerFieldNames{i}));
valueError = [valueError newValues];
slopeError = [slopeError newSlope];
end
valueError = reshape(valueError, 1, []);
slopeError = reshape(slopeError, 1, []);
end