Page 1 of 1
Modify expressions of ExpressionBasedBushingForce through MATLAB...
Posted: Tue May 07, 2019 12:47 pm
by stefanschmid
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
Re: Modify expressions of ExpressionBasedBushingForce through MATLAB...
Posted: Tue May 07, 2019 1:45 pm
by tkuchida
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().
Re: Modify expressions of ExpressionBasedBushingForce through MATLAB...
Posted: Thu May 16, 2019 12:22 pm
by stefanschmid
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
Re: Modify expressions of ExpressionBasedBushingForce through MATLAB...
Posted: Thu May 16, 2019 12:51 pm
by tkuchida
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()
Re: Modify expressions of ExpressionBasedBushingForce through MATLAB...
Posted: Thu May 16, 2019 1:21 pm
by stefanschmid
This is exactly what I was looking for and it works - thank you so much for your help Thomas!
-Stefan