Question: Matlab Documentation Cody Coursework Write a function that accepts a single input time_in_seconds that is an integer number of seconds and outputs a character array

Matlab Documentation

Cody Coursework

Write a function that accepts a single input time_in_seconds that is an integer number of seconds and outputs a character array TimeHMS expressing the time in hours:minutes:seconds format (HH:MM:SS with two characters for each). For example:

An input time of 54321 seconds would be 15 hours, 5 minutes, and 21 seconds. So the character array output would be TimeHMS = "15:05:21".

An input time of 5000 seconds would be 1 hour, 23 minutes, and 20 seconds. So the character array output would be TimeHMS = "01:23:20".

An input time of 300 seconds would be 5 minutes. So the character array output would be TimeHMS = "00:05:00".

The floor() function will be helpfuling solving this problem.

Use sprintf() to create the TimeHMS string. sprintf() input looks like that in fprintf(). fprintf() prints to the command window. sprintf() builds a string. See the text.

#TEST

Your Function

function [TimeHMS] = student_solution(time_in_seconds)

%Enter the commands for your function here. You can change the names of the input and/or output variables in the function command to match your code. Do not change the name of the function, however, as this exact name (i.e. "student_solution") is required for the test suite to run. Be sure to assign a value to the output variable.

TimeHMS = time_in_seconds;

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!