Page 1 of 1

Analyze Tool in Matlab: How to plot

Posted: Thu Nov 08, 2018 9:22 am
by aparziale
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 6 times
Arm26_Optimize_Setup_Analyze_generic.xml
(2.15 KiB) Downloaded 93 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();

Re: Analyze Tool in Matlab: How to plot

Posted: Fri Nov 09, 2018 3:07 am
by mitkof6
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

Re: Analyze Tool in Matlab: How to plot

Posted: Wed Nov 21, 2018 2:53 am
by matteo.m
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

Re: Analyze Tool in Matlab: How to plot

Posted: Wed Nov 21, 2018 4:37 am
by mitkof6
This function, must be available within the OpenSim Matlab bindings:

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