function v = velocity(v0, vmax, b, t0, t)
%velocity calculates the velocity from ignition to burnout and from apogee
% onward. Use velcoast to calculate from burnout to apogee.
%   v0 is the initial velocity.
%   vmax is the maximum or terminal velocity.
%   b is the b term in the equations. It's -g for descent.
%   t0 is the time at which the calculated phase begins.
%   t is the array of times for which the velocity is desired.
if vmax > v0
    v = vmax*tanh(b/vmax*(t-t0) + atanh(v0/vmax));
else
    v = vmax*coth(b/vmax*(t-t0) + acoth(v0/vmax));
end