Borrar filtros
Borrar filtros

fsolve not converging at F(x) = 0

2 visualizaciones (últimos 30 días)
Neilabh Banzal
Neilabh Banzal el 23 de Ag. de 2020
Comentada: Neilabh Banzal el 23 de Ag. de 2020
Hello,
I have written the attached code for solving the equilibrium of a rigid-link torsional spring model using fsolve.
However, when I evaluate the function values using the output of fsolve, I don't get 0 -
x = Equilibrium_Position
Equation solved.
fsolve completed because the vector of function values is near zero
as measured by the value of the function tolerance, and
the problem appears regular as measured by the gradient.
<stopping criteria details>
-0.4065 0.4065
x =
-0.4065 0.4065
>> k * (x(1) - x(2)) - g * l * sin(x(1)) * (M + m * (n_links - 0.5))
ans =
-8.6695e+04
>> k * (x(2) - x(1)) - g * l * sin(x(2)) * (M + m * 0.5)
ans =
8.6695e+04
I am unable to understant why this is happening. Any help/recommendation is welcome. Thanks!

Respuesta aceptada

Walter Roberson
Walter Roberson el 23 de Ag. de 2020
>> k * (x(1) - x(2)) - g * l * sin(x(1)) * (M + m * (n_links - 0.5))
You define most of those variables inside your function, and their values disappear when the function returns. You are not at a debug prompt.
We deduce that the visible values of some of the variables (in your base workspace) are not the same as the values in the code.
When I put in a breakpoint and ensure that I am using the values from the file, the calculates values are about 2E-13
  1 comentario
Neilabh Banzal
Neilabh Banzal el 23 de Ag. de 2020
Thanks a lot! Indeed, I have not updated the worksapce variables. Will keep this in mind in the future.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Programming en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by