Skip to main content

calculateJointError.m


% This function is part of the NMSM Pipeline, see file for full license.
%
% (string or Model, number, cellArray of string, string) -> (number)
% Returns the calculated cost function error for the given inputs


function error = calculateJointError(model, desiredError, jointNames, ...
markerFileName, accuracy)
model = Model(model);
params.markerNames = {};
params.desiredError = desiredError;
params.accuracy = accuracy;
for i=1:length(jointNames)
newMarkerNames = getMarkersFromJoint(model, jointNames{i});
for j=1:length(newMarkerNames)
if(~markerIncluded(params.markerNames, newMarkerNames{j}))
params.markerNames{end+1} = ...
newMarkerNames{j};
end
end
end
clear computeInnerOptimization
error = computeInnerOptimization([], {}, model, markerFileName, params);
error = sum(error.^2);
end