Analyze Tool in Matlab: How to plot

Provide easy-to-use, extensible software for modeling, simulating, controlling, and analyzing the neuromusculoskeletal system.
POST REPLY
User avatar
Antonio Parziale
Posts: 8
Joined: Thu Jan 16, 2014 5:14 am

Analyze Tool in Matlab: How to plot

Post by Antonio Parziale » Thu Nov 08, 2018 9:22 am

Dear all,

I'm using the model arm26.osim and I want to plot the passive fiber force versus the r_elbow_flex.
I was able to plot the function by using "Analyze Tool" available in the OpenSim GUI:
1)By Loading a motion file where time varies between 0 sec and 2 sec, r_shoulder_el is always 0 and r_elbow_flex varies between 0 and 90
Arm26_Optimize_q_sto.xml
(62.68 KiB) Downloaded 7 times
Arm26_Optimize_Setup_Analyze_generic.xml
(2.15 KiB) Downloaded 94 times
2)By Setting "Muscle Analysis" in Analysis Set;
3) By generating a plot with X_QUANTITY=r_elbow_flex and Y_QUANTITY=passive_fiber_force

I want to obtain the same plot by exploiting the MATLAB API.
I used the same motion file and the same model but I'm not able to show the same plot. In particular I'm not able to plot any variable as function of r_elbow_flex.
Can you help me?

Code: Select all

clear
clc

%% ARM26 ANALYZE

% First, import the classes from the jar file so that these can be called
% directly
import org.opensim.modeling.*

% Generate a new model object by loading the tug of war model from file
osimModel = Model('Arm26_Optimize.osim');

% Set up the visualizer to show the model and simulation
osimModel.setUseVisualizer(false);

% Initializing the model
osimModel.initSystem();

tool = AnalyzeTool('Arm26_Optimize_Setup_Analyze_generic.xml');

tool.setModel(osimModel);
tool.setName('AfferentAnalysis');
tool.setCoordinatesFileName('Arm26_Optimize_qcost.sto');
tool.setInitialTime(0.0);
tool.setFinalTime(2.0);

tool.run();

Tags:

User avatar
Dimitar Stanev
Posts: 1096
Joined: Fri Jan 31, 2014 5:14 am

Re: Analyze Tool in Matlab: How to plot

Post by Dimitar Stanev » Fri Nov 09, 2018 3:07 am

Please look at the plotting scripts for Python, which can be translated to Matlab

https://github.com/opensim-org/opensim- ... im/Scripts
https://simtk-confluence.stanford.edu/d ... in+the+GUI

User avatar
Matteo Musso
Posts: 12
Joined: Wed May 23, 2018 3:42 am

Re: Analyze Tool in Matlab: How to plot

Post by Matteo Musso » Wed Nov 21, 2018 2:53 am

Hi everyone, I'm also interested in plot my results with Matlab. I saw the Python code published by Dimitar, but I don't know how to translate this line of code into Matlab:

Code: Select all

crv1 = addAnalysisCurve(plotterPanel, "fiber-length", "rect_fem_r", "knee_angle_r")
That is the line for
Can you give me some advice? Please

User avatar
Dimitar Stanev
Posts: 1096
Joined: Fri Jan 31, 2014 5:14 am

Re: Analyze Tool in Matlab: How to plot

Post by Dimitar Stanev » Wed Nov 21, 2018 4:37 am

This function, must be available within the OpenSim Matlab bindings:

https://github.com/opensim-org/opensim- ... .java#L142

POST REPLY