Cannot find solution when using fsolve

3 次查看(过去 30 天)
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