Skip to main content

calcMaximumNormalizedFiberLengthDeviationCost.m


% This function is part of the NMSM Pipeline, see file for full license.
%
% (Array of number, struct) -> (Array of number)
% returns the cost for all rounds of the MuscleTendonLengthInitialization optimization


function cost = calcMaximumNormalizedFiberLengthDeviationCost(...
modeledValues, values, experimentalData, costTerm)
errorCenter = valueOrAlternate(costTerm, "errorCenter", 0);
maximumAllowableError = valueOrAlternate(costTerm, "maxAllowableError", 0.03);

maxNormalizedFiberLengths = ...
max(modeledValues.normalizedFiberLength, [], 3);

groupedMaxNormalizedFiberLengths = ...
values.maxNormalizedFiberLength(...
experimentalData.groupedMaxNormalizedFiberLength);

cost = calcTrackingCostArray(...
maxNormalizedFiberLengths, groupedMaxNormalizedFiberLengths, ...
errorCenter, ...
maximumAllowableError);
end