Answered step by step
Verified Expert Solution
Link Copied!

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

image text in transcribed

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Databases On The Web Designing And Programming For Network Access

Authors: Patricia Ju

1st Edition

1558515100, 978-1558515109

More Books

Students also viewed these Databases questions