Solve a nonlinear function with one variable
Mostrar comentarios más antiguos
Hi,
I need to solve this function using Matlab in single script:
x - x^2 + 2*{sin(x)*(x-1)} = 0
Would you be able to provide a sample code and method to do this in Matlab?
Thank you very much
Respuestas (2)
syms x
eq = x - x^2 + 2*sin(x)*(x-1) == 0
s = vpasolve(eq)
1 comentario
Mohiedin Bagheri
el 16 de En. de 2023
Editada: Mohiedin Bagheri
el 16 de En. de 2023
It is quite simple to solve this exercise. Just use vpasolve(), e.g.:
syms x
Solution = vpasolve(x-x^2+2*sin(x)*(x-1)==0)
An alternative way is to try Newton-Raphson method
2 comentarios
Mohiedin Bagheri
el 16 de En. de 2023
Editada: Mohiedin Bagheri
el 16 de En. de 2023
Sulaymon Eshkabilov
el 16 de En. de 2023
if you are talking about NR method, see this explanation. You'd need to use [for .. end] or [while ... end] loop. See this link where a bunch of matlab codes and discussions of NR method.
Categorías
Más información sobre Calculus en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!