% This function is part of the NMSM Pipeline, see file for full license.
%
% This function calculates the difference between the experimental and
% predicted muscle activations for the specified muscle.
%
% (2D matrix, Array of number, struct, Array of string) -> (Array of number)
%
function cost = calcTrackingMuscleActivationIntegrand(muscleActivations, ...
time, params, muscleName)
indx = find(strcmp(convertCharsToStrings(params.muscleNames), ...
muscleName));
if params.splineMuscleActivations.dim > 1
experimentalMuscleActivations = ...
fnval(params.splineMuscleActivations, time)';
else
experimentalMuscleActivations = ...
fnval(params.splineMuscleActivations, time);
end
experimentalMuscleActivations = fnval(params.splineMuscleActivations, time)';
cost = calcTrackingCostArrayTerm(experimentalMuscleActivations, ...
muscleActivations, indx);
end