# Question * Time Notation (number to formatted string) 1 solution submitted (max: 2) | View my solutions Code has already been provided to define a function named convertTime that accepts a single input variable timeInSeconds that is an integer number of seconds and defines the output variable TimeHMS. Add commands to the function that use the value in timelnSeconds to define string expressing the time in hours minutes seconds format (HH:MM:SS with two characters for each) and assign this string to the output string variable TimeHMS. For example: • An input time of 54321 seconds would be 15 hours, 5 minutes, and 21 seconds. So the output would be TimeHMS = "15:05:21". • An input time of 5000 seconds would be 1 hour, 23 minutes, and 20 seconds. So the output would be TimeHMS = "01:23:20". • An input time of 300 seconds would be 5 minutes. So the output would be TimeHMS = "00:05:00". Function ® C Reset MATLAB Documentation 1 function [TimeHMS] = convertTime (timeInSeconds) 2 %Enter the commands for your function here. Be sure to assign values %to the output variable TimeHMS defined in the function command on line 4 timeinSeconds = 54321 5 hrs = timeinSeconds/3600 6 fullhrs - floor(hrs) 7 mins = ((hrs-fullhrs)*60) 8 fullMins = floor(mins) 9 secs = round((mins-fullmins)*60) 10 TimeHMS = sprintf("%d:%d: %d", fullHrs, fullmins, secs) 11 TimeHMS = datestr(TimeHMS,'hh:MM:55') 12 end Code to call your function C Reset 1 [TimeHMS] = convertTime (54321)

TRD8B9 The Asker · Computer Science

Transcribed Image Text: * Time Notation (number to formatted string) 1 solution submitted (max: 2) | View my solutions Code has already been provided to define a function named convertTime that accepts a single input variable timeInSeconds that is an integer number of seconds and defines the output variable TimeHMS. Add commands to the function that use the value in timelnSeconds to define string expressing the time in hours minutes seconds format (HH:MM:SS with two characters for each) and assign this string to the output string variable TimeHMS. For example: • An input time of 54321 seconds would be 15 hours, 5 minutes, and 21 seconds. So the output would be TimeHMS = "15:05:21". • An input time of 5000 seconds would be 1 hour, 23 minutes, and 20 seconds. So the output would be TimeHMS = "01:23:20". • An input time of 300 seconds would be 5 minutes. So the output would be TimeHMS = "00:05:00". Function ® C Reset MATLAB Documentation 1 function [TimeHMS] = convertTime (timeInSeconds) 2 %Enter the commands for your function here. Be sure to assign values %to the output variable TimeHMS defined in the function command on line 4 timeinSeconds = 54321 5 hrs = timeinSeconds/3600 6 fullhrs - floor(hrs) 7 mins = ((hrs-fullhrs)*60) 8 fullMins = floor(mins) 9 secs = round((mins-fullmins)*60) 10 TimeHMS = sprintf("%d:%d: %d", fullHrs, fullmins, secs) 11 TimeHMS = datestr(TimeHMS,'hh:MM:55') 12 end Code to call your function C Reset 1 [TimeHMS] = convertTime (54321)
More
Transcribed Image Text: * Time Notation (number to formatted string) 1 solution submitted (max: 2) | View my solutions Code has already been provided to define a function named convertTime that accepts a single input variable timeInSeconds that is an integer number of seconds and defines the output variable TimeHMS. Add commands to the function that use the value in timelnSeconds to define string expressing the time in hours minutes seconds format (HH:MM:SS with two characters for each) and assign this string to the output string variable TimeHMS. For example: • An input time of 54321 seconds would be 15 hours, 5 minutes, and 21 seconds. So the output would be TimeHMS = "15:05:21". • An input time of 5000 seconds would be 1 hour, 23 minutes, and 20 seconds. So the output would be TimeHMS = "01:23:20". • An input time of 300 seconds would be 5 minutes. So the output would be TimeHMS = "00:05:00". Function ® C Reset MATLAB Documentation 1 function [TimeHMS] = convertTime (timeInSeconds) 2 %Enter the commands for your function here. Be sure to assign values %to the output variable TimeHMS defined in the function command on line 4 timeinSeconds = 54321 5 hrs = timeinSeconds/3600 6 fullhrs - floor(hrs) 7 mins = ((hrs-fullhrs)*60) 8 fullMins = floor(mins) 9 secs = round((mins-fullmins)*60) 10 TimeHMS = sprintf("%d:%d: %d", fullHrs, fullmins, secs) 11 TimeHMS = datestr(TimeHMS,'hh:MM:55') 12 end Code to call your function C Reset 1 [TimeHMS] = convertTime (54321)