In a function file named seconds convert .m, write a user defined function named
ID: 2082344 • Letter: I
Question
In a function file named seconds convert .m, write a user defined function named secondsconvert() that converts an input representing a natural number of seconds into an equivalent natural numbers of day(s), hour(s), minute(s), and second(s). Function secondsconvert() accepts one input argument named secondsIn and returns four output parameters named daysOut, hoursOut, minutesOut, and secondOut Input argument secondsIn represents the natural number of seconds that require conversion. Output arguments daysOut, hoursOut, minutesOut, and secondsOut represent the equivalent natural numbers of day(s), hour(s), minute(s), and second(s) indicated by secondsIn.Explanation / Answer
Function
--------------------------------------------------------------------------------------
function [daysOut, hoursOut, minutesOut, secondsOut]= secondsConvert()
clc;
secondsIn = input('Enter the seconds: ');
secondsOut = floor(mod(secondsIn,60))
minutesOut = floor(mod(secondsIn,3600) / 60)
hoursOut = floor(mod(secondsIn,86400) / 3600)
daysOut = floor(mod(secondsIn,(86400 * 30)) / 86400)
end
-------------------------------------------------------
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.