Question: 2. (20 points) Create an external function MpsTokmph.m for m/s-to-km/h conversion, that takes an input argument in m/s and outputs a value in km/h. 3.
2. (20 points) Create an external function "MpsTokmph.m" for m/s-to-km/h conversion, that takes an input argument in m/s and outputs a value in km/h. 3. Write a script "YourLastName A3 HW 2.m", which: (a) (10 pts) prompts the user to enter a value of the ocean depth in meters and assigns the value to a variable depth using the MATLAB input function. (b) (10 pts) Calculates the speed of a tsunami in meters per second according to the formula Utsunami = Vgd where g = 9.81 m/s2 and d is the depth of the ocean in meters. For your calculation set d = 4000 m. (c) (10 pts) Calculate the tsunami speed in km/h using your external function "Mpstokmph.m", and print the speed in km/h using the disp function. d) (10 pts) Calculate how far, in km, the tsunami will travel in 12 hours. (e) (20 pts) Create an internal function KmToMi, that takes an input value in kilometers, and converts the value to miles and returns that value to the main part of the script. Use it to convert the value obtained in (d) to miles. REMEMBER: internal functions MUST be placed at the end of your script. Your script should print out the speed of the tsunami in km/h and the distance travelled in kilometers and in miles using the fprintf function. There should be 1 digit after the decimal point. Make sure your script is commented (e.g., variable units, what the variable represents if it is not obvious)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
