Resolver ecuaciones simbólicas - MATLAB & Simulink - MathWorks España (2024)

La traducción de esta página aún no se ha actualizado a la versión más reciente. Haga clic aquí para ver la última versión en inglés.

Este ejemplo utiliza:

  • Symbolic Math ToolboxSymbolic Math Toolbox

Abrir script

Este ejemplo muestra los conceptos básicos para resolver ecuaciones simbólicas.

Resolver una ecuación cuadrática

Resuelva la ecuación cuadrática utilizando la función solve.

Resuelva la ecuación cuadrática sin especificar una variable que resolver. La función solve elige x para devolver la solución.

disp('Solve a quadratic equation without specifying which variable to solve for. The solve function chooses x to return a solution.')disp('>> syms a b c x')disp('>> eqn = a*x^2 + b*x + c == 0')disp('>> S = solve(eqn)')syms a b c xeqn = a*x^2 + b*x + c == 0S = solve(eqn)
Solve a quadratic equation without specifying which variable to solve for. The solve function chooses x to return a solution.>> syms a b c x>> eqn = a*x^2 + b*x + c == 0>> S = solve(eqn) eqn = a*x^2 + b*x + c == 0 S = -(b + (b^2 - 4*a*c)^(1/2))/(2*a)-(b - (b^2 - 4*a*c)^(1/2))/(2*a) 

Especifique la variable que desea resolver y resuelva la ecuación cuadrática para a.

disp('Solve for the variable a')disp('Sa = solve(eqn,a)')Sa = solve(eqn,a)
Solve for the variable aSa = solve(eqn,a) Sa = -(c + b*x)/x^2 

Resolver ecuaciones multivariante y asignar salidas a una estructura

Cuando se resuelven variables múltiples, puede que sea más conveniente guardar las salidas en un arreglo de estructura que en variables separadas. La función solve devuelve una estructura cuando especifica un único argumento de salida y existen múltiples salidas.

Resuelva un sistema de ecuaciones para devolver las soluciones en un arreglo de estructura.

disp('Solve a system of equations to return solutions in a structure array')disp('>> eqns = [2*u + v == 0, u - v == 1];')disp('>> S = solve(eqns,[u v])')syms u veqns = [2*u + v == 0, u - v == 1];S = solve(eqns,[u v])
Solve a system of equations to return solutions in a structure array>> eqns = [2*u + v == 0, u - v == 1];>> S = solve(eqns,[u v])S = struct with fields: u: 1/3 v: -2/3

Acceda a las soluciones refiriéndose a los elementos de la estructura.

disp('Access the solutions within the structure')disp('>> S.u')S.udisp('>> S.v')S.v
Access the solutions within the structure>> S.u ans = 1/3 >> S.v ans = -2/3 

Utilizar un arreglo de estructura permite sustituir soluciones convenientemente por otras expresiones. Utilice la función subs para sustituir las soluciones S por otras expresiones.

disp('Use the subs function to substitute the solutions into other expressions')disp('>> e1 = subs(u^2, S)')e1 = subs(u^2,S)disp('>> e2 = subs(3*v + u, S)')e2 = subs(3*v + u,S)
Use the subs function to substitute the solutions into other expressions>> e1 = subs(u^2, S) e1 = 1/9 >> e2 = subs(3*v + u, S) e2 = -5/3 

Si la función solve devuelve un objeto vacío, no existe una solución.

disp('The solve function returns an empty object if no solutions exist')disp('>> solve([3*u+2, 3*u+1],u)')S = solve([3*u+2, 3*u+1],u)
The solve function returns an empty object if no solutions exist>> solve([3*u+2, 3*u+1],u) S = Empty sym: 0-by-1 

Resolver ecuaciones numéricas

Cuando la función solve no puede resolver una ecuación simbólicamente, esta intenta encontrar una solución numérica utilizando la función vpasolve. La función vpasolve devuelve la primera solución que encuentra.

Intente resolver la siguiente ecuación. La función solve devuelve una solución numérica porque no puede encontrar una solución simbólica.

disp('The following equation returns a numeric solution because the solve function cannot find a symbolic solution')syms xdisp('>> eqn = sin(x) == x^2 - 1;')eqn = sin(x) == x^2 - 1;disp('>> solve(eqn,x)')S = solve(eqn,x)
The following equation returns a numeric solution because the solve function cannot find a symbolic solution>> eqn = sin(x) == x^2 - 1;>> solve(eqn,x)Warning: Unable to solve symbolically. Returning a numeric solution using <ahref="matlab:web(fullfile(docroot, 'symbolic/vpasolve.html'))">vpasolve</a>. S = -0.63673265080528201088799090383828 

Represente los lados izquierdo y derecho de la ecuación. Observe que la ecuación también tiene una solución positiva.

disp('Plot the left and right sides of the equation to see that the equation also has a positive solution')disp('>> fplot([lhs(eqn) rhs(eqn)], [-2 2])')fplot([lhs(eqn) rhs(eqn)], [-2 2])
Plot the left and right sides of the equation to see that the equation also has a positive solution>> fplot([lhs(eqn) rhs(eqn)], [-2 2])

Resolver ecuaciones simbólicas- MATLAB & Simulink- MathWorks España (1)

Encuentre la otra solución llamando directamente al solver numérico vpasolve y especificando el intervalo.

disp('Find the other solution by calling the numeric solver vpasolve')disp('>> V = vpasolve (eqn,x,[0,2])')V = vpasolve(eqn,x,[0 2])
Find the other solution by calling the numeric solver vpasolve>> V = vpasolve (eqn,x,[0,2]) V = 1.4096240040025962492355939705895 

Comando de MATLAB

Ha hecho clic en un enlace que corresponde a este comando de MATLAB:

 

Ejecute el comando introduciéndolo en la ventana de comandos de MATLAB. Los navegadores web no admiten comandos de MATLAB.

Resolver ecuaciones simbólicas- MATLAB & Simulink- MathWorks España (2)

Select a Web Site

Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .

You can also select a web site from the following list:

Americas

  • América Latina (Español)
  • Canada (English)
  • United States (English)

Europe

  • Belgium (English)
  • Denmark (English)
  • Deutschland (Deutsch)
  • España (Español)
  • Finland (English)
  • France (Français)
  • Ireland (English)
  • Italia (Italiano)
  • Luxembourg (English)
  • Netherlands (English)
  • Norway (English)
  • Österreich (Deutsch)
  • Portugal (English)
  • Sweden (English)
  • Switzerland
    • Deutsch
    • English
    • Français
  • United Kingdom (English)

Asia Pacific

Contact your local office

Resolver ecuaciones simbólicas
- MATLAB & Simulink
- MathWorks España (2024)

References

Top Articles
Latest Posts
Article information

Author: Velia Krajcik

Last Updated:

Views: 6104

Rating: 4.3 / 5 (54 voted)

Reviews: 93% of readers found this page helpful

Author information

Name: Velia Krajcik

Birthday: 1996-07-27

Address: 520 Balistreri Mount, South Armand, OR 60528

Phone: +466880739437

Job: Future Retail Associate

Hobby: Polo, Scouting, Worldbuilding, Cosplaying, Photography, Rowing, Nordic skating

Introduction: My name is Velia Krajcik, I am a handsome, clean, lucky, gleaming, magnificent, proud, glorious person who loves writing and wants to share my knowledge and understanding with you.