Question: MATLAB Problem 6.6 (Use Sub-functions- the primary function and sub-function distance should be in one *.m file) The distance to the horizon increases as you

MATLAB

Problem 6.6 (Use Sub-functions- the primary function and sub-function distance should be in one *.m file)

The distance to the horizon increases as you climb a mountain (or a hill). The expression

MATLAB Problem 6.6 (Use Sub-functions- the primary function and sub-function distance should

where d = distance to the horizon r = radius of the earth h = height of the hill

can be used to calculate that distance. The distance depends on how high the hill is and on the radius of the earth (or another planetary body).

(a) Create a function M-file called distance to find the distance to the horizon. Your function should accept two vector inputsradius and heightand should return the distance to the horizon. Dont forget that youll need to use mesh grid because your inputs are vectors.

(b) Create a MATLAB program that uses your distance function to find the distance in miles to the horizon, both on the Earth and on Mars, for hills from 0 to 10,000 feet. Remember to use consistent units in your calculations. Note that

Earths diameter = 7926 miles

Mars diameter = 4217 miles

Report your results in a table. Each column should represent a different planet, and each row a different hill height.

d = V2rh + h2

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!