How to compute eccentricity for elliptical

조회 수: 3 (최근 30일)
Mohammed  Alshehri
Mohammed Alshehri 2017년 2월 6일
댓글: Mohammed Alshehri 2017년 2월 6일
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
James Tursa
James Tursa 2017년 2월 6일
Are you simply asking how to calculate eccentricity from your initial state vector r and v?

댓글을 달려면 로그인하십시오.

답변 (1개)

James Tursa
James Tursa 2017년 2월 6일
  댓글 수: 1
Mohammed  Alshehri
Mohammed Alshehri 2017년 2월 6일
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

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Numerical Integration and Differential Equations에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by