Skip to main content

calcMassCenterVelocity.m


% This function is part of the NMSM Pipeline, see file for full license.
%
% This function calculates the center of mass velocity.
%
% (struct, Array of string, Cell) -> (2D matrix)
%


function massCenterVelocity = calcMassCenterVelocity(values, model, ...
coordinateNames)

import org.opensim.modeling.*
osimModel = Model(model);
osimModel.finalizeConnections();
osimState = osimModel.initSystem();
for j = 1 : length(values.time)
[osimModel, osimState] = setOsimStateBySingleFrame(values, osimModel, ...
osimState, coordinateNames, j);
massCenterVelocityVec = osimModel.calcMassCenterVelocity(osimState);
massCenterVelocity(j, :) = Vec3ToArray(massCenterVelocityVec);
end
end