2 Instructions Write a Matlab function called hw10m that com

2 Instructions Write a Matlab function called hw10.m that computes the maximum horizontal and vertical distance of a projectile and the total travel time, given the firing angle and initial velocity. Also, accept a third optional parameter that adjusts the gravitational constant (g = 9.8065 m2/s default). The angle input is degrees from horizontal, and velocity is m/s. You may need to consult a physics textbook or a reputable web resource such as https://en.wikipedia.org/wiki/Projectile_motion. Your function must do the following: • Use nargin to determine whether there is an optional g parameter given • Calculate the correct vertical and horizontal distances, and total travel time • Have sufficiently detailed comments in the appropriate location in the function such that typing help hw10 would completely describe how to use your function. • Use appropriate formatting for output information to the screen 3 Sample Output (four possibilities shown) >> hw09(38,15); x_max = 22.3 m y_max = 4.35 m t_max = 1.9 sec >> hw09(38,15) x_max = 22.3 m y_max = 4.35 m t_max = 1.9 sec ans = 22.2621 >> [xm, ym, tm] = hw09(38,15) x_max = 22.3 m y_max = 4.35 m t_max = 1.9 sec xm = 22.2621 ym = 4.3483 tm = 1.883 >> hw09(38,15,9.0); x_max = 24.3 m y_max = 4.74 m t_max = 2.1 sec

Solution

function [x_max,y_max,t_max]=hw10(ang,ivel,gr)
if(nargin==3)
g=gr
else
g=9.8065
end
t_max=(2*ivel*sin(ang))/g
y_max=(ivel*ivel*(1-cos(2*ang)))/(2*g)
x_max=(ivel*ivel*sin(2*ang))/g
end

2 Instructions Write a Matlab function called hw10.m that computes the maximum horizontal and vertical distance of a projectile and the total travel time, given

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site