How do I write the code for the following equation?

 Respuesta aceptada

Ameer Hamza
Ameer Hamza el 14 de Nov. de 2020
Editada: Ameer Hamza el 14 de Nov. de 2020
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 comentarios

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 el 14 de Nov. de 2020
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.
Ameer Hamza
Ameer Hamza el 14 de Nov. de 2020
I am glad to be of help!

Iniciar sesión para comentar.

Más respuestas (0)

Preguntada:

el 14 de Nov. de 2020

Comentada:

el 14 de Nov. de 2020

Community Treasure Hunt

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

Start Hunting!

Translated by