Page 1 of 1

Update prescribed force

Posted: Tue Apr 16, 2019 5:48 am
by anacsousa
Hello, if anyone could help me with this topic.

I am able to create this force (at the model), but I do not know how I change it in Matlab, during forward simulation

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
How can I get this pelvis_Force and change its ForceFunction during simulation?

Re: Update prescribed force [Matlab script]

Posted: Tue Apr 16, 2019 6:24 am
by jimmy
You would be better off to use ExternalForce(). You would create a time history of the force vector and location then add that to add it to the model.

Re: Update prescribed force

Posted: Wed Apr 17, 2019 6:06 am
by anacsousa
Thanks for the response.
So, is it a prescribed force? Is there a way to make it dependable to another variable? In a way that I could change it dynamically? (similarly to the way that we can do to a torque in a joint)

Re: Update prescribed force

Posted: Wed Apr 17, 2019 7:55 am
by jimmy
So, is it a prescribed force?
No, it is an external force. They are different. I suggested that because you can assign the location of the point over time. However, I do see now that PrescribedForce() has a method for assigning a pointFunction(), so you just need to define the function you want for location over time.

Re: Update prescribed force

Posted: Thu Apr 18, 2019 7:14 am
by anacsousa
Both options (prescribed and external) are only defined by functions over time?
Is there a way to make it defined over another variable, for example?

For example, something like "if the knee joint is higher than 45 deg, force = 10, otherwise force = 0"?