Return a specific solution vpasolve

조회 수: 1 (최근 30일)
Brian Robinson
Brian Robinson 2020년 5월 1일
편집: Ameer Hamza 2020년 5월 1일
Hello there,
For the following code:
Q = 4.3; s_0 = 0.003; n = 0.025; L = 30; k_e = 0.5; C_D = 0.65; H = 3.6; 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],3.5)
Solving this gives the wrong solution. When we graph the two equations, we can see that there are two solutions. I want to return the first solution and hence I have used the initial guess of 3.5, however vpasolve still gives the other solution.
How can I get the first solution i.e. 1<D<1.5 ?
Thanks,
Brian

채택된 답변

Ameer Hamza
Ameer Hamza 2020년 5월 1일
편집: Ameer Hamza 2020년 5월 1일
Try this
sol = vpasolve([eqn1, eqn2], [deltaH, D], [0 1.25]) % give two values for initial guess, for [delhaH D]
%^ use comma. Using == in this context is incorrect.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Conversion Between Symbolic and Numeric에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by