Please help to spot the error here
1 view (last 30 days)
Show older comments
This is a solved example in the book 'Applied numerical methods with MATLAB by Chapra'
A bungee jumper jumps off a cliff 200 m high with an upward velocity of 20 m/s. Detemine when he hts the ground and plot dist vs time and velocity vs time.
The problem is solved in the book as below : Assuming DOWNWARD direction is positive (i.e. distance (y), velocity (v) and force are positive downards, and x = 0 at ground levele. The boundary conditions are : x(0) = -200 m/s, v(0) = -20 m/s
The diff eqn being solved is : md2y/dt2 = Fdown - Fup = mg - cd / m * v^2
The following functions are written
1. Function for derivative --- Here
function dydt=freefall(t,y,cd,m)
% y(1) = x and y(2) = v
grav=9.81;
dydt=[y(2);grav-cd/m*y(2)*abs(y(2))];
end
2. Function to detect event of hitting the ground
% Event function
function [detect,stopint,direction]=endevent(t,y,varargin)
% Locate the time when height passes through zero
% and stop integration.
detect=y(1); % Detect height = 0
stopint=1; % Stop the integration
direction=0; % Direction does not matter
end
3. Script file to run the problem
% Script file
opts=odeset('events',@endevent);
y0=[-200 -20];
[t,y,te,ye]=ode45(@freefall,[0 inf],y0,opts,0.25,68.1);
te,ye
plot(t,y(:,1),'-',t,y(:,2),'--','LineWidth',2)
legend('Height (m)','Velocity (m/s)')
xlabel('time (s)');
ylabel('x (m) and v (m/s)')
end
The answer for this is : jumper hits the ground after 9.5475 s at 46.2454 m/s (downward)
==================================================================================== I am trying to solve THE SAME problem using the following convention :
Assuming UPWARD direction is positive (i.e. distance (y), velocity (v) and force are positive downards, and x = 0 at ground levele. the boundary conditions are : x(0) = 200 m, v(0) = 20 m/s
The diff eqn being solved is : md2y/dt2 = -Fdown + F up = -mg + cd / m * v^2
The following functions are written
1. Function for derivative
% code
function dydt=freefall(t,y,cd,m)
% y(1) = x and y(2) = v
grav=9.81;
dydt=[y(2);-grav + cd/m*y(2)*abs(y(2))];
end
2. Function to detect event of hitting the ground
% code
function [detect,stopint,direction]=endevent(t,y,varargin)
% Locate the time when height passes through zero
% and stop integration.
detect=y(1); % Detect height = 0
stopint=1; % Stop the integration
direction=0; % Direction does not matter
end
3. Script file to run the problem
% code
opts=odeset('events',@endevent);
y0=[200 20];
[t,y,te,ye]=ode45(@freefall,[0 inf],y0,opts,0.25,68.1);
te,ye
plot(t,y(:,1),'-',t,y(:,2),'--','LineWidth',2)
legend('Height (m)','Velocity (m/s)')
xlabel('time (s)');
ylabel('x (m) and v (m/s)')
end
The answer for this is : jumper hits the ground after 8.0142 s at -104.8502 m/s (downward)
I am unable to spot the error. Will someone PLEASE explain where the mistake is ?
TIA
0 Comments
Answers (0)
See Also
Categories
Find more on Environmental Models in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!