% This function is part of the NMSM Pipeline, see file for full license.
%
% This function fits muscle tendon lengths and moment arms as a
% function of joint angles for all muscles
%
% Inputs:
% jointAngles (numberFrames x degreesOfFreedom)
% muscleTendonLengths (numberFrames x 1)
% momentArms (numberFrames x degreesOfFreedom)
% polynomialDegree (value)
%
% (2D Number matrix, Number array, 2D Number matrix, Number) ->
% (Symbol array, 2D Symbol array, Number array)
%
% returns polynomial expressions with corresponding coefficients that
% best fit experimental muscle tendon lengths and moment arms for all
% muscles.
% -----------------------------------------------------------------------
function [polynomialExpressionMuscleTendonLengths, ...
polynomialExpressionMuscleTendonVelocities, ...
polynomialExpressionMomentArms, coefficients] = ...
createSurrogateModel(jointAngles, muscleTendonLengths, ...
momentArms, polynomialDegree)
% Create surorogate model for all muscles
for i = 1 : size(muscleTendonLengths, 2)
[polynomialExpressionMuscleTendonLengths{i}, ...
polynomialExpressionMuscleTendonVelocities{i}, ...
polynomialExpressionMomentArms{i}, coefficients{i}] = ...
createMuscleSpecificSurrogateModel(jointAngles{i}, ...
muscleTendonLengths(:, i), momentArms{i}, polynomialDegree);
end
end