Code covered by the BSD License

# Optimal Impulsive Orbital Transfer

### David Eagle (view profile)

27 Nov 2012 (Updated )

MATLAB script for the solution of the one and two impulse orbit transfer between two Earth orbits.

primer(dtof, rt1eci, vt1eci, dv1eci, dv2eci)
```function iopt = primer(dtof, rt1eci, vt1eci, dv1eci, dv2eci)

% examine primer vector and its derivative for optimality

% Orbital Mechanics with MATLAB

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

global soln pvi pvdi

% magnitude of primer vector tolerance

tol_pv = 1.001;

% magnitude of primer derivative tolerance

tol_pvd = 0.00001;

% initialize optimality flag

iopt = 0;

% perform primer vector initialization

pviniz(dtof, rt1eci', vt1eci', dv1eci', dv2eci');

% define number of data points to create and process

npts = 300;

% compute behavior of primer vector magnitude

dt = dtof / npts;

for i = 1:1:npts + 1

t = (i - 1) * dt;

if (t == 0)

% initial value of primer magnitude and derivative

pvm = norm(pvi);

pvdm = dot(pvi, pvdi) / pvm;

else

% primer vector and derivative magnitudes at time t

[pvm, pvdm] = pvector(rt1eci, vt1eci, t);

end

x1(i) = t;

y1(i) = pvm;

y2(i) = pvdm;

end

% -----------------------------------------------------------------------
% if primer conditions are satisfied, create text and graphics disk files
% -----------------------------------------------------------------------

if (y1(1) <= tol_pv && y1(end) <= tol_pv && max(y1) <= tol_pv ...
&& abs(y2(1)) <= tol_pvd && abs(y2(end)) <= tol_pvd)

iopt = 1;

% increment solution number

soln = soln + 1;

% create text file of solutions

make_textfile(soln);

% create trajectory graphics file

tgraphics(soln, dtof);

% create primer graphics file

pgraphics(soln, x1, y1, y2);

end

```