I'm trying to simulate a person making a bungee-jump. To do this I am using the ode45 command.
So, the person jumps from an unspecified height, and the rope, L=50m, starts to unfold at that moment. However it does not generate a pulling force (S) until the person actually reaches 50m. Then it decelerates the person until the turning point, where it's starting to accelerate the jumper. When he reaches the 50m mark again, it's the same as before, the force in the rope should be zero. So, I need the ode to make the force in the rope == 0 when it's not fully streched, i.e u(1) > 0, since I've defined the origin where the rope is at L. (u(1) is the y-location in the xy-plane).
I was initially trying to make this happen using if-statements (such as: If u(1)>0) for the input-function, but MatLab was not too happy with me using u(1) as an if-condition. So maybe ODE Event Location is the way to go. But I haven't used it before, and feel a bit confused about the arguments and whatnot.
I would try to create the event function something like this:
function [value,isterminal,direction] = some_handle
But I'm unsure how to write the syntax to connect that function to the values of 'u', and also how I would solve the constant "on/off" switches of the rope-force S.
Here is my code currently, where I've removed my failing attempts at making the ode event location work.
Hopefully this was not too much, and I would really appritiate som help.
(There is also air-resistance --> c*v^2)
g=9.81; mass=75; c=0.1; L=50; k=130;
f=[u(2); g - sign(u(2))*c*u(2)^2/mass - k*u(1)/mass];