How Does Air Resistance Affect Falling Objects in MATLAB Simulations?

AI Thread Summary
The discussion focuses on simulating the motion of a falling object affected by air resistance in MATLAB, using a differential equation that incorporates velocity squared. The parameters include gravitational acceleration (g = 9.81 m/s²), mass (m = 68.1 kg), and a resistance coefficient (c = 1.5 kg/m). Users are seeking assistance with implementing the 4th order Runge-Kutta method for numerical solutions alongside the exact solution for velocity over a specified time interval. A code snippet is provided, but it contains an error where the velocity vector 'v' is not properly initialized, leading to confusion in the simulation. The conversation emphasizes the need for correct coding practices to ensure accurate results in MATLAB simulations.
Mech-Master
Messages
13
Reaction score
0

Homework Statement



An object of mass m falls from rest at a point near the Earth's surface. If the air resistance is proportional to the velocity v^2, the differential equation for the velocity as a function of time is given by m*dv/dt = mg - cv^2

For the given paraments g = 9.81 m/s^2. m = 68.1 kg and c = 1.5 kg/m. plot the exact solution and the numerical solution v(t) obtained from the 4th order predictor-corrector runge kutta methods using an interval of dt = 0.25 seconds in the domain of 0<t<6

(I need help with the code of runga kutta, I am horrible at matlab


Homework Equations



m*dv/dt = mg - cv^2


The Attempt at a Solution





clear
clc
g = 9.81
m = 68.1
c = 1.5
tmax = 6
dt = 0.25
t = [0:dt:tmax]
v(1) =1;

%Exact Solution
vs = sqrt(m*g/c)*tanh(t*sqrt(g*c/m));
plot(t,vs,'s'), hold on

%Runge-Kutta
for i = 1:length(t)-1
f= g - c*v(i).^2/m;
k1= f(v(i));
k2= f(t(i)+(dt/2), v(i) + (dt/2)*k1);
k3 =f(t(i)+(dt/2), v(i) + (dt/2)*k2);
k4 =f(t(i)+ dt, + v(i) + dt*k3);
v(i+1) = v(i) + (dt/6)*(k1+2*k2+2*k3+k4);
end
 
Physics news on Phys.org
If you look in the first row of the for loop, the vector v is not defined so the code dosen't make sense.
 

Similar threads

Replies
4
Views
2K
Replies
1
Views
3K
Replies
15
Views
3K
Replies
2
Views
2K
Replies
4
Views
3K
Replies
2
Views
8K
Replies
1
Views
3K
Replies
0
Views
1K
Replies
7
Views
3K
Back
Top