Skip to main content

makeMarkerWeightSet.m


% This function is part of the NMSM Pipeline, see file for full license.
%
% This function makes a marker weight set from the names of the markers and
% weights such that the name and weight at the same index of their arrays
% will be matched.
%
% (Array of string, Array of number) -> (MarkerWeightSet)
% Generate a MarkerWeightSet from an array of names and weights


function markerWeightSet = makeMarkerWeightSet(markerNames, weights)
if(length(markerNames) ~= length(weights))
throw(MException('',strcat('Marker name array and weight array ', ...
'are not the same length')))
end
import org.opensim.modeling.*
markerWeightSet = SetMarkerWeights();
for i=1:length(markerNames)
markerWeightSet.cloneAndAppend(MarkerWeight( ...
markerNames(i), weights(i)));
end
end