How do I write the code for the following equation?

Raindrop acceleration equation:
dv(t)/dt = g - Cd * (Pa/Pw)* (3v(t)*2/4d)
Given that v(0) = 0

 Accepted Answer

If you have symbolic toolbox, you can find the symbolic solution
syms v(t)
g = 9.8;
Pa = 1;
Pw = 2;
d = 5;
Cd = 0.2;
eq = diff(v) == g - Cd*(Pa/Pw)*3*v(t)*2/(4*d);
IC = v(0) == 0;
sol = dsolve(eq, IC);
fplot(sol, [0 200])
Result
Otherwise, you can find the numerical solution using ode45()
g = 9.8;
Pa = 1;
Pw = 2;
d = 5;
Cd = 0.2;
dv = @(t,v) g - Cd*(Pa/Pw)*3*v*2/(4*d);
IC = 0;
tspan = [0 200];
[t, y] = ode45(dv, tspan, IC);
plot(t, y)

6 Comments

Thanks. However, I have to use the data above to complete the work. So do you mean that I just have to change the value of diameter to obtain the value?
The given density of water is 1000 kg/m^3. When I changed the value of Pw to 1000, the graph becomes a straight line instead of curve. How do I fix this?
Yes, you just need to change the parameters. Can you give me the set of parameters which create straight line?
I use the small drop with diameter = 0.5mm as an example from the table (sent above).
It is also curved. But the curve starts at large value of 't'. Increase the tspan
tspan = [0 5000];
It works now. Thanks so much.
I am glad to be of help!

Sign in to comment.

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!