Question: Write a user defined Matlab function that determines the time elapsed between two events during a day. For the function name and arguments, use dt=timediff(TA,
Write a user defined Matlab function that determines the time elapsed between two events during a day. For the function name and arguments, use dt=timediff(TA, ap1, TB, ap2). The input arguments to the function are:
TA is a two element vector with the time of he second event. The first element is the hour and the second element is the minute.
ap1 is a string 'AM' or 'PM' which corresponds to the time of the first event.
TB is a two element vector with the time of the second event. The first element is the hour and the second element the hour and the second element is the minute.
ap2 is a string 'AM' or 'PM' which corresponds to the time of the first event.
The output argument dt is a two element vector with the time elapsed between two events. The first element is the number of hours and the second element is number of minutes. The function displays an error message if the time entered for event B is before the time entered for event A. Use the function to determine the time elapesd between the following events:
a) Event A: 5:37AM; Event B: 2:51PM
b) Event A: 12:53AM: Event B: 6:12PM
c) Event A: 11:32PM; Event B: 3:18pm
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
