Change forces in Matlab

Provide easy-to-use, extensible software for modeling, simulating, controlling, and analyzing the neuromusculoskeletal system.
POST REPLY
User avatar
Ana de Sousa
Posts: 58
Joined: Thu Apr 07, 2016 4:21 pm

Change forces in Matlab

Post by Ana de Sousa » Tue Mar 26, 2019 5:44 am

Hello, I would like to know how may I change a force through Matlab code.
I know that for torques is:

Code: Select all

osimModel.updActuators().get('gear_load').addInControls(Vector(1, controlActionLoad(controlIteration)), modelControls);
But I would like to apply a force in a specific direction and in a specific point in a body. I would also like to change it at each iteration.

I appreciate any help with this matter.

User avatar
Dimitar Stanev
Posts: 1096
Joined: Fri Jan 31, 2014 5:14 am

Re: Change forces in Matlab

Post by Dimitar Stanev » Thu Mar 28, 2019 2:13 am


User avatar
Ana de Sousa
Posts: 58
Joined: Thu Apr 07, 2016 4:21 pm

Re: Change forces in Matlab

Post by Ana de Sousa » Tue Apr 09, 2019 1:05 pm

Thank you for the response, Dimitar!

May I ask you how do I use PrescribedForce in Matlab? The example from the link is in cpp, and when I look for the same name in Matlab (PrescribedForce), it does not find it in org.opensim.modeling.*

User avatar
Ana de Sousa
Posts: 58
Joined: Thu Apr 07, 2016 4:21 pm

Re: Change forces in Matlab

Post by Ana de Sousa » Tue Apr 09, 2019 1:09 pm

Sorry, actually, I am able to create the force, but I do not know how I change it in Matlab.

Code: Select all

% Create force
pelvis_Force = PrescribedForce(pelvis);

pelvis_Force.setName('pelvis_force');
pelvis_Force.setForceFunctions(Constant(0), Constant(250), Constant(0));

% Add the force to the model
osimModel.addForce(pelvis_Force); % Add the force to the model

POST REPLY