Hi

It seems that I'm not able to figure out how to modify the expressions (e.g. <Mx_expression>) of an ExpressionBasedBushingForce through MATLAB. Can anyone help me with that?

Thanks

-Stefan

## Modify expressions of ExpressionBasedBushingForce through MATLAB...

- Stefan Schmid
**Posts:**7**Joined:**Wed Apr 05, 2017 4:50 am

- Thomas Uchida
**Posts:**1110**Joined:**Wed May 16, 2012 11:40 am

### Re: Modify expressions of ExpressionBasedBushingForce through MATLAB...

Here is the documentation for the

**ExpressionBasedBushingForce**class in OpenSim 3.3:**https://simtk.org/api_docs/opensim/api_ ... Force.html**. You can use the**methodsview**function in Matlab to see which methods are available from this class through the Matlab scripting interface (see https://simtk-confluence.stanford.edu:8 ... ith+Matlab). I don't have a test environment, but you could try**setMxExpression()**or**set_Mx_expression()**.- Stefan Schmid
**Posts:**7**Joined:**Wed Apr 05, 2017 4:50 am

### Re: Modify expressions of ExpressionBasedBushingForce through MATLAB...

Thanks for the reply Thomas!

However, I could still not figure out how to do it. I have a model, which includes the expression-based bushing force "L5S1_Disc_forces". In the OpenSim GUI, I can see this force under Forces/Other Forces. And when I run the following code in MATLAB, I can "see" the force as well.

import org.opensim.modeling.*

modelpath = ['xxxxxxxxx.osim'];

myModel = Model(modelpath);

BushingForce = myModel.getForceSet().get(635);

What would now be the code to read out the properties (e.g. Mx_Expression) of this force through MATLAB?

Please let me know if you need more information.

Thanks a lot for your help!

-Stefan

However, I could still not figure out how to do it. I have a model, which includes the expression-based bushing force "L5S1_Disc_forces". In the OpenSim GUI, I can see this force under Forces/Other Forces. And when I run the following code in MATLAB, I can "see" the force as well.

import org.opensim.modeling.*

modelpath = ['xxxxxxxxx.osim'];

myModel = Model(modelpath);

BushingForce = myModel.getForceSet().get(635);

What would now be the code to read out the properties (e.g. Mx_Expression) of this force through MATLAB?

Please let me know if you need more information.

Thanks a lot for your help!

-Stefan

- Thomas Uchida
**Posts:**1110**Joined:**Wed May 16, 2012 11:40 am

### Re: Modify expressions of ExpressionBasedBushingForce through MATLAB...

Please see the "Common Scripting Commands" page in the Confluence documentation (https://simtk-confluence.stanford.edu:8 ... g+Commands -- search the page for "downcast"). In short, you need to tell MATLAB that the object is of type ExpressionBasedBushingForce, not just a generic Force object. You should have something like this:

Code: Select all

```
myModel = Model('filename.osim');
force = myModel.getForceSet.get('nameOfComponent');
ebbf = ExpressionBasedBushingForce.safeDownCast(force);
ebbf.getMxExpression()
ebbf.setMxExpression('theta_x+2*theta_x^2')
ebbf.getMxExpression()
```

- Stefan Schmid
**Posts:**7**Joined:**Wed Apr 05, 2017 4:50 am

### Re: Modify expressions of ExpressionBasedBushingForce through MATLAB...

This is exactly what I was looking for and it works - thank you so much for your help Thomas!

-Stefan

-Stefan