use of "fsolve" function
Afficher commentaires plus anciens
[EDIT: 20110722 22:40 CDT - merge additional material from Answer]
Hello there,
I have a new problem concerning the use of fsolve, it seems that it's not working for my function, I double checked my code but I can't really find my mistake. Since I am a new matlab user, I am asking for help to find out what's wrong with my script.
Thanks a lot in advance for helping,
Romain
Here below is my code:
function sol_ = ssrepeat1( i0_ , a0_ , m_ , n_ , e_ )
rad_ = 180 / pi;
initial_guess_ = [i0_ a0_];
options_ = optimset('MaxFunEvals',1e8);
var_ = fsolve(@(var_) ssrepeat( var_ , e_ , m_, n_), initial_guess_, options_ );
sol_(1) = var_(1) * rad_;
sol_(2) = var_(2);
end
function result_ = ssrepeat( var_ , e_ , m_ , n_ )
i_ = var_(1);
a_ = var_(2);
deg_ = pi / 180;
re_ = astro_constants(23);
mu_ = astro_constants(13);
we_ = 7.292115e-5;
J2_ = 1082.62622070e-6;
omega_dot_ = - sqrt( mu_ / a_ ^ 3 ) * ( re_ / a_ ) ^ 2 * ( ( 3 * J2_ ) / ( 2 * ( 1 - e_ ^ 2 ) ^ 2 ) ) * cos( i_ * deg_ );
w_dot_ = - sqrt( mu_ / a_ ^ 3 ) * ( re_ / a_ ) ^ 2 * ( ( 3 * J2_ ) / ( 2 * ( 1 - e_ ^ 2 ) ^ 2 ) ) * ( ( 5 / 2 ) * sin( i_ * deg_ ) ^ 2 - 2 );
n_tilt_ = - sqrt( mu_ / a_ ^ 3 ) * ( 1 - ( re_ / a_ ) ^ 2 * ( ( 3 * J2_ ) / ( 2 * ( 1 - e_ ^ 2 ) ^ ( 3 / 2 ) ) ) * ( ( 3 / 2 ) * sin( i_ * deg_ ) ^ 2 - 1 ) );
result_(1) = ( ( m_ / n_ ) / ( we_ - omega_dot_ ) ) - 1 / ( w_dot_ + n_tilt_ );
result_(2) = cos( i_ * deg_ ) + ( ( 2 * we_ * a_ ^ ( 3 / 2 ) * ( 1 - e_ ^ 2 ) ) / ( 3 * J2_ * re_ ^ 2 * sqrt( mu_ ) ) );
end
[Additional material moved from Answer]
I used the following inputs:
i0_ = 100 ° (orbital inclination)
a0_= 8000 km (semimajor axis)
m_ = 271 orbits
n_ = 19 nodal days
e_ = 0 (eccentricity for a circular orbit)
Here is what I get when I ran the script:
sol_ = ssrepeat1( 100 , 8000 , 271 , 19 , 0. )
Maximum number of function evaluations reached:
increase options.MaxFunEvals.
sol_ =
1.0e+03 *
-0.2544 7.7800
Or I should normally get something like:
98° and 7190 km
This script aims to design a sun-synchronous orbit repeating its ground track.
When I decrease my initial guess, the solution keeps on decreasing.
Last but not least, I basically tried to derive the following algorithm:
Hope it helps,
Romain
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Programming dans Centre d'aide et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!