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

 採用された回答

Ameer Hamza
Ameer Hamza 2020 年 11 月 14 日
編集済み: Ameer Hamza 2020 年 11 月 14 日

0 投票

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 件のコメント

Choi Ying WONG
Choi Ying WONG 2020 年 11 月 14 日
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?
Ameer Hamza
Ameer Hamza 2020 年 11 月 14 日
Yes, you just need to change the parameters. Can you give me the set of parameters which create straight line?
Choi Ying WONG
Choi Ying WONG 2020 年 11 月 14 日
I use the small drop with diameter = 0.5mm as an example from the table (sent above).
Ameer Hamza
Ameer Hamza 2020 年 11 月 14 日
It is also curved. But the curve starts at large value of 't'. Increase the tspan
tspan = [0 5000];
Choi Ying WONG
Choi Ying WONG 2020 年 11 月 14 日
It works now. Thanks so much.
Ameer Hamza
Ameer Hamza 2020 年 11 月 14 日
I am glad to be of help!

サインインしてコメントする。

その他の回答 (0 件)

Community Treasure Hunt

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

Start Hunting!

Translated by