How to compute eccentricity for elliptical

17 vues (au cours des 30 derniers jours)
Mohammed  Alshehri
Mohammed Alshehri le 6 Fév 2017
how to make matlab compute eccentricity for elliptical figure that I am creating. I am creating elliptical using numerical method. See code below and attached.
clear all
clc
%* Set initial position and velocity of the comet.
r0 = 1 ;
v0 = pi;
r = [r0 0]; v = [0 v0];
%* Set physical parameters (mass, G*M)
GM = 4*pi^2; % Grav. const. * Mass of Sun (au^3/yr^2)
mass = 1.; % Mass of comet
adaptErr = 1.e-4; % Error parameter used by adaptive Runge-Kutta
time = 0;
%* Loop over desired number of steps using specified
% numerical method.
nStep = 1000;
tau = 0.001;
for iStep=1:nStep
%* Record position and energy for plotting.
rplot(iStep) = norm(r); % Record position for polar plot
thplot(iStep) = atan2(r(2),r(1));
tplot(iStep) = time;
kinetic(iStep) = .5*mass*norm(v)^2; % Record energies
potential(iStep) = - GM*mass/norm(r);
% Euler-Cromer step
accel = -GM*r/norm(r)^3;
v = v + tau*accel;
r = r + tau*v;
time = time + tau;
unwrap_theta=unwrap(thplot);
if unwrap_theta(iStep) > 2*pi
break
end
end
%* Graph the trajectory of the comet.
figure(1); clf; % Clear figure 1 window and bring forward
q=polar(thplot,rplot,'-'); % Use polar plot for graphing orbit
xlabel('Distance (AU)'); grid;
  1 commentaire
James Tursa
James Tursa le 6 Fév 2017
Are you simply asking how to calculate eccentricity from your initial state vector r and v?

Connectez-vous pour commenter.

Réponses (1)

James Tursa
James Tursa le 6 Fév 2017
  1 commentaire
Mohammed  Alshehri
Mohammed Alshehri le 6 Fév 2017
I am trying to find out if there is a function in matlab that can calculate the eccentricity from the figure or from theta and r coordinates

Connectez-vous pour commenter.

Catégories

En savoir plus sur Numerical Integration and Differential Equations dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by