How to use "fsolve" to solve nonlinear simultaneous equations

4 visualizaciones (últimos 30 días)
Sho Bunno
Sho Bunno el 23 de Jun. de 2020
Respondida: Sho Bunno el 24 de Jun. de 2020
I want to solve nonlinear simultaneous equations by using the function "fsolve".
I can solve a nonliner equations by using "fsolve".
However, I have the following error message when I try to solve nonlinear simultaneous equations.
Could you tell me how to modify my code?
syms x1 x2
equ1=x1^2 - 1;
equ2=x2*x1 - 3;
test1=matlabFunction(equ1);
solve1 = fsolve(test1, [0.5])
% solve1 is correct.
test2=matlabFunction(equ1, equ2);
solve2 = fsolve(test2, [0, 0])
% Error!

Respuesta aceptada

Sho Bunno
Sho Bunno el 24 de Jun. de 2020
Thanks, everyone.
I have solved the problem by myself.
syms x1 x2
equ1=x1^2 - 1;
equ2=x2*x1 - 3;
equs=[equ1;equ2];
myfun = matlabFunction(equs);
fun= @(x) myfun(x(1),x(2))
solve= fsolve(fun, [0, 0])

Más respuestas (1)

KSSV
KSSV el 23 de Jun. de 2020
syms x1 x2
eqns = [x1^2-1==0, x1*x2-3==0] ;
sol = solve(eqns,[x1, x2])
  1 comentario
Sho Bunno
Sho Bunno el 23 de Jun. de 2020
Thank you for your quick response.
However, I want to use "fsolve" because I want to adjust the tolerance for solving another equations.
I apologize for my lack of words.

Iniciar sesión para comentar.

Categorías

Más información sobre Systems of Nonlinear Equations en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by