Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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 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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started