# Solve a system of nonlinear equations symbolically

1 visualización (últimos 30 días)
Aleem Andrew el 21 de Oct. de 2020
Comentada: Aleem Andrew el 22 de Oct. de 2020
The following code is meant to solve a system of nonlinear equations.
syms do K
eq1 =(5e-5)^2 - (do)^2 == K*25*60;
eq2 = (7.5e-5)^2 - (do)^2 == K*98*60;
sol = solve(eq1,eq2);
fprintf("%s%f\n%s%f","do: ",sol.do,"K: ",sol.K)
The output is
do: -0.000038
9211259166826217642^(1/2)/80264348827648NaN755578637259143/10590190179824151570426101760.000000
do is correctly formatted but despite the format specficiation K is formatted incorrectly and the string "K: " is not displayed. Can someone explain why this is happening?
##### 0 comentariosMostrar -2 comentarios más antiguosOcultar -2 comentarios más antiguos

Iniciar sesión para comentar.

### Respuesta aceptada

Walter Roberson el 21 de Oct. de 2020
You have a polynomial system. MATLAB is finding all solutions. Your format is only expecting one solution.
##### 1 comentarioMostrar -1 comentarios más antiguosOcultar -1 comentarios más antiguos
Aleem Andrew el 22 de Oct. de 2020
Thank you for your help

Iniciar sesión para comentar.

### Categorías

Más información sobre Symbolic Math Toolbox en Help Center y File Exchange.

### Community Treasure Hunt

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

Start Hunting!

Translated by