Skip to main content

calcSynergyWeightsSum.m


% This function is part of the NMSM Pipeline, see file for full license.
%
% This function calculates the sum of the specified synergy weight group.
%
% (Array of number, struct, Array of string) -> (Number)
%


function synergyWeightsSum = calcSynergyWeightsSum(synergyWeights, ...
synergyGroups, synergyGroupName)

numSynergiesIndex(1) = 0;
numMusclesIndex(1) = 0;
for i = 1 : length(synergyGroups)
temp = find(strcmp(convertCharsToStrings(synergyGroups{i}.muscleGroupName), ...
synergyGroupName));
if ~isempty(temp)
indx = i;
end
end
for j = 1 : indx
numSynergiesIndex(end+1) = numSynergiesIndex(end) + ...
synergyGroups{j}.numSynergies;
numMusclesIndex(end+1) = numMusclesIndex(end) + ...
size(synergyGroups{j}.muscleNames, 2);
end
synergyWeightsSum = sum(synergyWeights(1 + numSynergiesIndex(end-1): ...
numSynergiesIndex(end), 1 + numMusclesIndex(end-1) : ...
numMusclesIndex(end)), 2)';
end