필터 지우기
필터 지우기

fsolve not converging at F(x) = 0

조회 수: 1 (최근 30일)
Neilabh Banzal
Neilabh Banzal 2020년 8월 23일
댓글: Neilabh Banzal 2020년 8월 23일
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!

채택된 답변

Walter Roberson
Walter Roberson 2020년 8월 23일
>> 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
Neilabh Banzal
Neilabh Banzal 2020년 8월 23일
Thanks a lot! Indeed, I have not updated the worksapce variables. Will keep this in mind in the future.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Get Started with MATLAB에 대해 자세히 알아보기

태그

제품


릴리스

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by