Thank you for your responses and your codes.
I am also interested in computing the MTU Length using the Matlab API with the Rajagopal's model.
I succeeded to obtain the length of the semitendinosus tendon unit during a trial of a passive sollicitation of the knee, using this following code :
Code: Select all
%% I got a variable named Data, corresponding to the different coordinates of the models in radian for rotational coordinates and in meters for translational coordinates.
%Choose the muscle that you want to plot
musclelist = {};
Nmuscle = model.getMuscles().getSize();
for i = 0: Nmuscle-1
thisName = char(model.getMuscles().get(i).getName());
musclelist = [musclelist; {thisName} ];
end
string = input('Type a muscle name to plot, or ''exit'' to close: ', 's');
nameIndex = find(cellfun(@(s) ~isempty(strmatch(string, s)), musclelist) == 1);
musclename = char(musclelist(nameIndex));
%Definition
num_timepoints = size(Data,1);
num_coordinates = size(Data,2);
muscle_set = model.getMuscles();
num_muscles = muscle_set.getSize();
%Compute muscle lengths at each time point in the motion by updating the state
musclelengths=zeros(1,num_timepoints);
for t=1:num_timepoints
for i=0:num_coordinates-1 %38
model.updCoordinateSet().get(i).setValue(state,Data(t,i+1));
end
model.realizePosition(state)
muscle=muscle_set.get(nameIndex-1);
musclelengths(1,t)=muscle.getLength(state);
end
It seems to work. The results obtained correspond to the ones that I get after performing a MuscleAnalysis. Nevertheless, this code takes a lot of time to run (The trial lasts 8.16 seconds so I got 817 frames).
So, I would like to know, if it is also the case for you or if you have any idea to decrease this run time.
Thank you
Regards