Splitting time into hours : minutes : seconds from a fractional value.

11 ビュー (過去 30 日間)
WASIM ASHRAF
WASIM ASHRAF 2021 年 4 月 19 日
コメント済み: WASIM ASHRAF 2021 年 4 月 21 日
Hello Everyone,
Can anyone help me for converting a fractional value in the time format?
e.g. 15.76 = HH:MM:SS format.
  1 件のコメント
WASIM ASHRAF
WASIM ASHRAF 2021 年 4 月 19 日
how to write a function for this?
Any help will be appreciated.

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

採用された回答

Stephan
Stephan 2021 年 4 月 19 日
I guess 15.76 means hours in decimal numbers:
[h,m,s] = hms(hours(15.76))
d = duration(h,m,s)
gives:
h =
15
m =
45
s =
36
d =
duration
15:45:36
  2 件のコメント
Walter Roberson
Walter Roberson 2021 年 4 月 19 日
t = hours(15.76);
t.Format = 'hh:mm:ss'
t = duration
15:45:36
WASIM ASHRAF
WASIM ASHRAF 2021 年 4 月 21 日
Thanks Stephan, due to this small code my full problem was stuck. Now my code is working fine.
Thanks a lot.

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

その他の回答 (0 件)

カテゴリ

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