I am trying to extract muscle properties and moment arms from an OpenSim model across a dynamic task. I have prescribed a motion for the model using the example script 'prescribeMotionInModel.m', but I do not understand how to cycle through the states of the motion in order to extract the parameters at different time points. I have tried setting the coordinate values to the values in the prescribed function individually (shown below), but I believe that there should be a more efficient way to cycle through the prescribed motion.
Is there a way to directly specify a time during a prescribed motion in order to extract muscle parameters at that time?
Code: Select all
% Here is the code for my hack
for ii = 1:72
for jj = 1:coords.getSize
joint = model.updCoordinateSet().get( jj-1 ); % Extract specific coordinate from model
func = joint.get_prescribed_function; % Get prescribed function from coordinate
temp(ii) = func.calcValue( Vector( 1, 0.4+1.2*(ii-1)/71 )); % Calculate the prescribed value for a certain time point
joint.setValue( states, temp( ii ), false ); % Set the coordinate value to the one calculated for the specified time point
end
% extract relevant parameters
end