Skip to main content

updateMuscleModelProperties.m


% This function is part of the NMSM Pipeline, see file for full license.
%
% If muscles are present, this model updates the optimal fiber length, max
% isometric force, and tendon slack length values based on changes
% resulting from design optimization or from updated values from the
% osimx file.
%
% (struct) -> (struct)
% Updated muscle model properties in the osim model


function inputs = updateMuscleModelProperties(inputs)
if ~isa(inputs.model, 'org.opensim.modeling.Model')
inputs.model = Model(inputs.model);
end
if strcmp(inputs.controllerType, 'synergy_driven')
for i = 1 : inputs.numMuscles
inputs.model.getForceSet().getMuscles().get(inputs.muscleNames(i)). ...
setOptimalFiberLength(inputs.optimalFiberLength(i));
inputs.model.getForceSet().getMuscles().get(inputs.muscleNames(i)). ...
setTendonSlackLength(inputs.tendonSlackLength(i));
inputs.model.getForceSet().getMuscles().get(inputs.muscleNames(i)). ...
setMaxIsometricForce(inputs.maxIsometricForce(i));
end
end