Cannot find solution when using fsolve

3 ビュー (過去 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 Center および File ExchangeImage Processing Toolbox についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by