Cannot find solution when using fsolve

조회 수: 8 (최근 30일)
Baichuan Jiang
Baichuan Jiang 2016년 3월 23일
답변: Star Strider 2016년 3월 23일
Hi all,
I am trying to solve the following nonlinear equations using fsolve:
basex=-60.0235;
basey=-7.0012;
options=optimset('Algorithm','levenberg-marquardt');
X=fsolve(@(x)[basex/sqrt(4*x(2)^2*x(1)^2+1)...
-basey*2*x(2)*x(1)/sqrt(4*x(2)^2*x(1)^2+1)+x(1);...
basex*2*x(2)*x(1)/sqrt(4*x(2)^2*x(1)^2+1)...
+basey/sqrt(4*x(2)^2*x(1)^2+1)+x(1)^2*x(2)],[59;-0.001],options)
However, I was told no solution found. Acctually there should be a solution, because the basex and basey value is generated through the same set of equations:
x=[60;-0.002];
A=[1/sqrt(4*x(2)^2*x(1)^2+1) -2*x(2)*x(1)/sqrt(4*x(2)^2*x(1)^2+1) x(1);
2*x(2)*x(1)/sqrt(4*x(2)^2*x(1)^2+1) 1/sqrt(4*x(2)^2*x(1)^2+1) x(1)^2*x(2);
0 0 1];
B=[0;0;1];
Base=linsolve(A,B) % basex=Base(1),basey=Base(2)
Anyone can help me with this? Thanks a lot!
-Bay

답변 (1개)

Star Strider
Star Strider 2016년 3월 23일
You need to do element-wise operations using the dot (.) operator:
basex=-60.0235;
basey=-7.0012;
options=optimset('Algorithm','levenberg-marquardt');
X=fsolve(@(x)[basex./sqrt(4*x(2).^2.*x(1).^2+1)...
-basey*2.*x(2).*x(1)./sqrt(4*x(2).^2.*x(1).^2+1)+x(1);...
basex*2*x(2).*x(1)./sqrt(4*x(2).^2.*x(1).^2+1)...
+basey./sqrt(4*x(2).^2.*x(1).^2+1)+x(1).^2.*x(2)],[59;-0.001],options)
X =
35.1460e-006
-4.9918e-003
See the documentation on: Array vs. Matrix Operations for details.

카테고리

Help CenterFile Exchange에서 Image Processing Toolbox에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by