Skip to main content

findSynergyWeightsByGroup.m


% This function is part of the NMSM Pipeline, see file for full license.
%
% This function finds the synergy weights from the design variables and
% arranges them in an array where the first index indicates the synergy
% group a set of weights belongs to. This is used in the bilateral symmetry
% cost term.
%
% (Array of double, struct) -> (Array of double)
% Finds synergy weights from design variables array


function weights = findSynergyWeightsByGroup(values, inputs)
weights = zeros(length(inputs.synergyGroups), ...
inputs.synergyGroups{1}.numSynergies, ...
length(inputs.synergyGroups{1}.muscleNames));
valuesIndex = 1;
for i = 1:length(inputs.synergyGroups)
weights(i, :, :) = ...
reshape(values(valuesIndex : valuesIndex + ...
length(inputs.synergyGroups{i}.muscleNames) * ...
inputs.synergyGroups{i}.numSynergies - 1), size(weights, 2), []);
valuesIndex = valuesIndex + ...
length(inputs.synergyGroups{i}.muscleNames) * ...
inputs.synergyGroups{i}.numSynergies;
end
end