Skip to main content

calcTrackingExternalMomentsIntegrand.m


% This function is part of the NMSM Pipeline, see file for full license.
%
% This function calculates the difference between the experimental and
% predicted ground reaction moments for the specified moment.
%
% (struct, 2D matrix, Array of number, Array of string) -> (Array of number)
%


function cost = calcTrackingExternalMomentsIntegrand(params, ...
groundReactionMoments, time, loadName)

for i = 1:length(params.contactSurfaces)
indx = find(strcmp(convertCharsToStrings(params.contactSurfaces{i}. ...
momentColumns), loadName));
if ~isempty(indx)
if params.splineExperimentalGroundReactionMoments{i}.dim > 1
experimentalGroundReactions = ...
fnval(params.splineExperimentalGroundReactionMoments{i}, ...
time)';
else
experimentalGroundReactions = ...
fnval(params.splineExperimentalGroundReactionMoments{i}, ...
time);
end
cost = calcTrackingCostArrayTerm(...
experimentalGroundReactions, groundReactionMoments{i}, ...
indx);
end
end
end