In this example we calculate the acceleration of gravity and the escape velocity at the Sun and Earth surface.
clc;clear all; G = 6.67384E-11; %Gravitational constant,[m^3kg-1s-2]
Sun
Ms = 1.98855e30; %Solar mass [kg] Rs = 6.955e8; %Solar radius [m] V_esc = (2*G*Ms/Rs)^0.5/1000; %Escape velocity [km/s] g = G*Ms/Rs^2; %Acceleration of gravity[m*s-2] fprintf('Acceleration of gravity[m*s-2] %4.2f \n',g); fprintf('Escape velocity [km/s] %4.2f \n\n',V_esc);
Acceleration of gravity[m*s-2] 274.36 Escape velocity [km/s] 617.76
Earth
Me = 5.98e24; %Earth mass [kg] Re = 6378000; %Earth radius [m] V_esc = (2*G*Me/Re)^0.5/1000; %[km/s] g = G*Me/Re^2; %Acceleration of gravity[m*s-2] fprintf('Acceleration of gravity[m*s-2] %4.2f \n',g); fprintf('Escape velocity [km/s] %4.2f \n',V_esc);%% Earth
Acceleration of gravity[m*s-2] 9.81 Escape velocity [km/s] 11.19