How could I make a script for this ecuation where i can solve for f?

29 visualizaciones (últimos 30 días)
Jorge
Jorge el 20 de Nov. de 2024 a las 21:39
Comentada: Torsten el 20 de Nov. de 2024 a las 23:43
  5 comentarios
Walter Roberson
Walter Roberson el 20 de Nov. de 2024 a las 23:19
Editada: Walter Roberson el 20 de Nov. de 2024 a las 23:20
rng(655321)
epsilon = rand
epsilon = 0.3140
D = rand
D = 0.3864
Re = rand
Re = 0.1855
eqn = @(x) x + 2*log10(epsilon/D/3.7+2.51*x/Re);
X = fzero(eqn, [0 1e5])
X = 0.0533

Iniciar sesión para comentar.

Respuestas (1)

Walter Roberson
Walter Roberson el 20 de Nov. de 2024 a las 22:05
Editada: Walter Roberson el 20 de Nov. de 2024 a las 23:23
syms f epsilon D Re
Q = @(v) sym(v);
eqn = 1/sqrt(f) == -Q(2.0) * log(epsilon/D/Q(3.7) + Q(2.51)/(Re*sqrt(f)))
F = solve(eqn, f)
Warning: Solutions are only valid under certain conditions. To include parameters and conditions in the solution, specify the 'ReturnConditions' value as 'true'.
disp(char(F))
(86248369*D^2)/(1000*Re*epsilon - 18574*wrightOmega((500*Re*epsilon)/(9287*D) - log(251/(50*Re)))*D)^2
wrightOmega is a function in the Symbolic Toolbox
rng(655321)
epsilon = rand
epsilon = 0.3140
D = rand
D = 0.3864
Re = rand
Re = 0.1855
f = subs(F)
disp(char(vpa(f)))
322.8497917132456879511724468922
subs(eqn)
disp(char(vpa(ans)))
0.055654430712142653567619972363646 == 0.055654430712142653567619972363646

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by