Code covered by the BSD License
 cgl(np, a, b)
computes nodes and weights of the
 defect_trap(tk, tkp1, xk,...state vector defects  trapezoid method
 dto_guess(ti, tf, xi, xf,...compute linear guess
 dto_rhs (t, x, u)
firstorder equations of motion
 dtofunc_trap (x)
objective function and equality constraints
 dto_trap.m
 dto_trap_64bit.m

View all files
Aerospace Trajectory Optimization Using Direct Transcription and Collocation
by
David Eagle
06 Nov 2012
(Updated
07 Jul 2014)
Demonstrates the solution of an aerospace trajectory optimization problem.

dto_guess(ti, tf, xi, xf, ngrid)

function xg = dto_guess(ti, tf, xi, xf, ngrid)
% compute linear guess
% required by dto_trap.m
% input
% ti = initial time
% tf = final time
% xi = initial state vector component
% xf = final state vector component
% ngrid = number of grid points in guess
% output
% xg = array of initial guesses
% Orbital Mechanics with MATLAB
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% create array of time values at CGL grid points
[t, w] = cgl(ngrid, ti, tf);
% compute slope
xm = (xf  xi) / (tf  ti);
% compute data at grid points
xg(1) = xi;
xg(ngrid) = xf;
for i = 2: ngrid  1
xg(i) = xm * t(i) + xi;
end


Contact us