I am trying to use inputs and loops to allow the user to choose whether they would like to go to the moon or mars, and their orbital distance, and have the program give the user the required velocity. If anybody has any ideas on how make this work, or a better way to code it I would apreciate it a lot.
input('Which planet would yoy like to orbit? (Moon/Mars): ','s');Mars = {3.71,3389500};[g02,Re2] = Mars{:};Moon = {1.26,1737125.91};[g01,Re1] = Moon{:};% g02 and g01 represents gravitational constant and Re2 and Re1 represents mean radius.
for index = Mars h = input('What height would you like to orbit at above Mars? '); Velocity = sqrt((g02*Re2.^2)/(Re2+h)); for index1 = Moon h = input('What height would you like to orbit at above the Moon? '); Velocity = sqrt((g01*Re2.^2)/(Re1+h)); endendfprintf('The speed rquired to orbit at this altitude is %8.2f Meters/Sec \n' ,Velocity);
Best Answer