Question: matlab question a) Write a MATLAB user-defined function, freefall(), that computes the velocity and the distance of a free fall object, given its initial position
a) Write a MATLAB user-defined function, freefall(), that computes the velocity and the distance of a free fall object, given its initial position and the time travelled as two input arguments. The velocity and the distance of a free fall object can be written as: y = gt y=% + gt where yo is the initial position, t is the time travelled and g is the acceleration due to gravity (-9.81 m/s?). The initial position can only be a scalar value, and thus the function can only work with a scalar input for this value. The time traveled can be a MATLAB vector array or a scalar, and the function should work if either of these are input for this variable. The function should display an error message if a negative time is input. Do not forget to include proper comments. Flow chart is NOT required. b) Use the user-define function created in Part a). Write the proper MATLAB statement(s) to compute the velocity (v) and the travelled distance (y) for a free fall object with the initial position (yo) of 20 meters and the time ranging from 0 to 10 seconds, step 0.1s. Use the subplot function to plot, on the same figure window, the time versus the velocity and the time versus the travelled distance. Do not forget to include proper comments in the code. A Flow chart is NOT required
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
