Accessing model properties through Matlab API

Provide easy-to-use, extensible software for modeling, simulating, controlling, and analyzing the neuromusculoskeletal system.
POST REPLY
User avatar
Nathaniel Smith
Posts: 2
Joined: Fri Mar 13, 2015 9:16 pm

Accessing model properties through Matlab API

Post by Nathaniel Smith » Fri Sep 23, 2016 12:32 pm

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

User avatar
jimmy d
Posts: 1375
Joined: Thu Oct 04, 2007 11:51 pm

Re: Accessing model properties through Matlab API

Post by jimmy d » Fri Nov 04, 2016 2:26 pm

Hi, Nate-

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



POST REPLY