フィルターのクリア

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

7 ビュー (過去 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.
  2 件のコメント
Walter Roberson
Walter Roberson 2021 年 9 月 28 日
Seconds relative to what base time?
Walter Roberson
Walter Roberson 2021 年 9 月 28 日
See functions such as seconds() -- and mod()

サインインしてコメントする。

回答 (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!
  1 件のコメント
Walter Roberson
Walter Roberson 2021 年 10 月 1 日
Not exactly, as it does not return these as numeric as required for the homework

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeDates and Time についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by