Page 1 of 1

Change forces in Matlab

Posted: Tue Mar 26, 2019 5:44 am
by anacsousa
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.

Re: Change forces in Matlab

Posted: Thu Mar 28, 2019 2:13 am
by mitkof6

Re: Change forces in Matlab

Posted: Tue Apr 09, 2019 1:05 pm
by anacsousa
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.*

Re: Change forces in Matlab

Posted: Tue Apr 09, 2019 1:09 pm
by anacsousa
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