Question
Matlab script help? I have to use Matlab script file to create a program that calculates to force between 2 masses(planets), based on their distance,
Matlab script help?
I have to use Matlab script file to create a program that calculates to force between 2 masses(planets), based on their distance, using newton's law of Universal Gravitation; F=G*m(a)*m(b) all over r^2. Where G=6.673x10-11 Nm2/kg2. The program must represent numerical values as variables(not using the actual numbers) The program must a user in the command window for two masses of the two bodies and a range of distances(10 distances total, ranging from 3.8x108 m to 4.0x108). Program should output to the command window, a table with distances in column 1 and forces in column 2, both printed to 4 significant digits. I've gotten as far as the following(the following script in matlab), But i can't figure out how to make it enter a range of r values, or output to a table.
%clear window
clc
%equation -> force exerted by one celestial body on another as a function of distance F=(G*m1*m2)/(r^2
G=6.673*10^-11; %Newton's Gravitational Constant
m1=input ('enter mass of planet 1');
m2=input ('enter mass of planet 2');
r=input ('enter range of distances between planet 1 and planet 2');
F=G*m1*m2./r.^2
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started