Write a script that computes the force of gravity between two objects given their masses and the distance between them.
7 views (last 30 days)
Show older comments
One pound on Earth equals 4.4537 Newton's of force on Earth Script assumes that mass1, mass2, and distance already exist in the workspace The script should store the results of the computations in the variables gravitationalForceNewtons and gravitationalForceLbs
Answers (1)
Image Analyst
on 7 Nov 2016
Here's a start
function force = ComputeGravitationalForce(m1, m2, distance)
force = G * m1 * m2 / .............
You finish. You can insert a second line and finish the last line. Actually, it's extremely trivial.
7 Comments
Walter Roberson
on 8 Nov 2016
We pulled the numbers from Rosemary's code. They are arbitrary test values.
When you are calculating for real situations make sure you get the units right. For example are the masses in grams, kilograms, or pounds? Are the distances in kilometres, metres, centimetres, miles, inches?
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!