Error Using Solve Function

Hello there,
I'm getting an error using the solve function. What is the reason for this and how do we correct it? See below.
Q = 5; s_0 = 0.005; n = 0.02; L = 35; k_e = 0.5; C_D = 0.65; H = 4; g = 9.81;
syms D deltaH
A = pi*D^2/4;
V = Q/A;
R_H = D/4;
eqn1 = deltaH == H - D + L*s_0;
eqn2 = deltaH == (k_e + 2*g*n^2*L/R_H^(4/3) + 1)*(Q^2/(2*g*A^2));
deltaH = double(solve(eqn1 == eqn2, D,"Real",true))
Thanks very much,
Brian

7 comentarios

darova
darova el 30 de Abr. de 2020
It's too complicated. Try vpasolve or fsolve
Brian Robinson
Brian Robinson el 1 de Mayo de 2020
Ok so lets use vpa solve:
How would I specify that the solution for D must be less than H/1.2 = 3.33?
So far I have the below code which gives a nonsense solution and I believe there could be more solutions which aren't being shown.
Q = 5; s_0 = 0.005; n = 0.02; L = 35; k_e = 0.5; C_D = 0.65; H = 4; g = 9.81;
syms D deltaH
A = pi*D^2/4;
V = Q/A
R_H = D/4;
eqn1 = deltaH == H - D + L*s_0
eqn2 = deltaH == (k_e + (2*g*n^2*L)/(R_H^(4/3)) + 1)*((Q^2)/(2*g*A^2))
[deltaH, D] = vpasolve(eqn1 == eqn2, deltaH, D);
Thanks again,
Brian
darova
darova el 1 de Mayo de 2020
try initial guess
Brian Robinson
Brian Robinson el 1 de Mayo de 2020
No that didn't seem to make a difference.
darova
darova el 1 de Mayo de 2020
Makes difference for me
deltaH =
4.1628911435565798210779440646728
D =
10.0
Brian Robinson
Brian Robinson el 1 de Mayo de 2020
When I try it I get deltaH = 10 and D = 4.138. Which is the same answer as I got with no parameter.
Regardless, I want to get the other solution which is 1 < D < 2. I can see this solution when I graph the two equations.
darova
darova el 1 de Mayo de 2020
What about this
[deltaH, D] = vpasolve(eqn1 == eqn2, [deltaH, D],[2 1])
deltaH =
1.1885695516004419959725632337124
D =
2.0
[deltaH, D] = vpasolve(eqn1 == eqn2, [deltaH, D],[2 4])
deltaH =
4.1628911435565798210779440646728
D =
2.0

Iniciar sesión para comentar.

Respuestas (0)

Etiquetas

Preguntada:

el 30 de Abr. de 2020

Comentada:

el 1 de Mayo de 2020

Community Treasure Hunt

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

Start Hunting!

Translated by