Question: 3. Create the function calcHours(t1,t2) function that takes two inputs, t1 and t2, and determines the elapsed time. Both inputs should be decimal numbers, in

 3. Create the function calcHours(t1,t2) function that takes two inputs, t1

3. Create the function calcHours(t1,t2) function that takes two inputs, t1 and t2, and determines the elapsed time. Both inputs should be decimal numbers, in hours, that represent time in a 24-hour format. For example, 1:30 pm would be 13:30 in 24-time. The corresponding decimal value would be 13.5. t1 should be the start time and t2 should be the stop time. Your code should still work past midnight! Print the elapsed time (output from the function) in the main .m script using an fprintf(). Use the following function header: function [hours] = calcHours (ti, t2) Determines the elapsed time between tl and t2 Inputs: tl- the starting time in decimal hours t2- the ending time in deciaml hours Outputs: hours- the elapsed time between tl and t2 in decimal hours This is an example run of this function: elapsedTime = calcHours (13.5,16); Time between 1:30pm and 4:00pm fprintf('The elapsed time is %.2f hours. ', elapsedTime); N W An here is the printed output in the Command Window: Command Window The elapsed time is 2.50 hours

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!