% This function is part of the NMSM Pipeline, see file for full license.
%
% This function calculates the cost for tracking values
%
% (Array of number, Array of number, number, number) -> (struct)
% returns tracking cost
function cost = calcTrackingCostTerm(modelValue, experimentalValue, ...
errorCenter, maxAllowableError)
errorMatching = modelValue - experimentalValue;
cost = ((errorMatching - errorCenter) ./ maxAllowableError) .^ 2 ./ ...
numel(errorMatching);
cost(isnan(cost))=0;
cost = sum(cost, 'all');
end