Skip to main content

calcDeviationCostTerm.m


% This function is part of the NMSM Pipeline, see file for full license.
%
% This function calculates the cost that penalize the changes in parameter
% values
%
% (Array of number, number, number) -> (Array of number)
% returns cost that penalizes differences


function cost = calcDeviationCostTerm(value, ...
errorCenter, maxAllowableError)
cost = ((value - errorCenter) ./ maxAllowableError) .^ 2 ./ ...
numel(value);
cost(isnan(cost)) = 0;
cost = sum(cost, 'all');
end