Hi there - I am new to the OpenSim-Matlab interface! I'd like to do a few calculations in Matlab, using values from my scaled OpenSim model - scaled from gait2392.
Using "strengthScaler.m" (comes in the OpenSim download package) as a starting point, I have managed to read in muscle property values (OptimalFiberLength and MaxIsometricForce) from my scaled model. I would also like to use the API to read in properties of the model's bodies. Specifically, I would like the mass of each body so that I can sum them to create a whole_body_mass variable in Matlab. Since the masses of bodies is contained in the .osim file, ideally I'd like to use something as simple as "model_bodies = currentModel.getBodies" but I can't seem to find commands that will:
A) result in a list of bodies in the model; and then
B) report the mass of those bodies
Any help would be greatly appreciated! Thank you in advance - Nate
Accessing model properties through Matlab API
- Nathaniel Smith
- Posts: 2
- Joined: Fri Mar 13, 2015 9:16 pm
Re: Accessing model properties through Matlab API
Hi, Nate-
You could use something like this
You could use something like this
Code: Select all
import org.opensim.modeling.*
model = Model('myModel.osim')
% get the set of bodies
bodyset = model.getBodySet
% get number of bodies
nBodies = bodyset.getSize
% get the mass of the first body
mass = bodyset.get(0).getMass