fsolve

1 次查看(过去 30 天)
Romain W
Romain W 2011-7-20
I want to solve a system of non linear equations using fsolve but it seems like it's not working well. You can see the code below:
function f = myfun2(x)
mu_ = astro_constants(13);
re_ = astro_constants(23);
deg_ = pi / 180;
ra_ = 35785.922;
fpa_entry_ = -4.0;
sin_theta_e_ = ( - sqrt( mu_ * ( 2 * x(1) * re_ - re_ ^ 2 - x(1) ^ 2 * ( 1 - x(2) ^ 2 ) ) / ( x(1) * re_ ^ 2 ) ) / x(2) ) * sqrt( ( x(1) * ( 1 - x(2) ^ 2 ) ) / mu_ );
cos_theta_e_ = ( x(1) * ( 1 - x(2) ^ 2 ) / ( x(2) * re_ ) ) - 1 / x(2);
x(1) = ra_ / ( 1 + x(2) );
f = [ tan( fpa_entry_ * deg_ ) - ( x(2) * sin_theta_e_ ) / ( 1 + x(2) * cos_theta_e_ ) ; x(1) - ra_ / ( 1 + x(2) ) ];
My initial guess:
x0 = [ [0 100000] , [0 1] ]
[x, fval] = fsolve(@myfun2,x0)
Can someone let me know why this routine is actually not working?
Thanks for your help,
R.
  1 个评论
the cyclist
the cyclist 2011-7-20
Can you please include the values of all constants (e.g. "astro_constants")?
Also, what do you mean by "not working"? Does it give an error or warning, or just not give the answer you expect?

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Manual Performance Optimization 的更多信息

标签

产品

Community Treasure Hunt

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

Start Hunting!

Translated by