How to convert decimal to time?

8 ビュー (過去 30 日間)
oshawcole
oshawcole 2017 年 10 月 10 日
編集済み: Peter Perkins 2017 年 10 月 13 日
eg: 7.6 (7+0.6*60) = 7:36

採用された回答

per isakson
per isakson 2017 年 10 月 10 日
編集済み: per isakson 2017 年 10 月 10 日
datestr takes days as input. Thus, divide by 24.
>> val = 7.6;
>> datestr( val/24, 'HH:MM' )
ans =
07:36
I guessed that seven is hours, not minutes.
  1 件のコメント
oshawcole
oshawcole 2017 年 10 月 10 日
How do I do it if I want 7:36 PM?

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

その他の回答 (1 件)

Peter Perkins
Peter Perkins 2017 年 10 月 13 日
編集済み: Peter Perkins 2017 年 10 月 13 日
This depends on what you mean by "time". Likely, the most useful thing is a duration:
>> t = hours(7.6)
t =
duration
7.6 hr
>> t.Format = 'hh:mm:ss'
t =
duration
07:36:00

カテゴリ

Help Center および File ExchangeElementary Math についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by