% Speed around an ellipse using vis-viva
mu_km3_s2 = 398600.4418;
a_km = 14000;
e = 0.35;
nu = linspace(0, 2*pi, 721);
r_km = a_km*(1-e^2) ./ (1 + e*cos(nu));
v_km_s = sqrt(mu_km3_s2 .* (2./r_km - 1/a_km));

plot(rad2deg(nu), v_km_s, 'LineWidth', 1.8)
grid on
xlabel('True anomaly (degrees)')
ylabel('Orbital speed (km/s)')
title('Vis-viva speed around an elliptical orbit')

