Skip to main content

getNumEnabledMuscles.m


% This function is part of the NMSM Pipeline, see file for full license.
%
% This function takes a loaded OpenSim Model and iterates through the force
% set to identify all muscles. If they are enabled, count them and return
% the final count.
%
% (Model) -> (number)
% Counts the number of enabled muscles in a model


function count = getNumEnabledMuscles(model)
count = 0;
if ~isa(model, 'org.opensim.modeling.Model')
model = Model(model);
end
for i =0:model.getForceSet().getMuscles().getSize()-1
if(model.getForceSet().getMuscles().get(i).get_appliesForce())
count = count + 1;
end
end
end