Cannot find solution when using fsolve

3 views (last 30 days)
Baichuan Jiang
Baichuan Jiang on 23 Mar 2016
Answered: Star Strider on 23 Mar 2016
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

Answers (1)

Star Strider
Star Strider on 23 Mar 2016
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.

Categories

Find more on Image Processing Toolbox in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!