How do I write a function that inputs seconds and outputs the number of days, hours, and mins?

9 次查看(过去 30 天)
I'm confused in writing a function that can take seconds as an input and provides an output in the number of days, hours, minutes, and seconds, if applicable.

回答(1 个)

Shanmukha Voggu
Shanmukha Voggu 2021-10-1
Hi,
Using Format property of the duration solves the issue
tim=seconds(94255)
tim = duration
94255 sec
tim.Format='dd:hh:mm:ss'
tim = duration
01:02:10:55
Refer this for more information about seconds function
Hope this helps!

类别

Help CenterFile Exchange 中查找有关 Mathematics 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by