convert min, hours to 00:00:00 format

20 ビュー (過去 30 日間)
Sonima
Sonima 2019 年 8 月 27 日
回答済み: Guillaume 2019 年 8 月 27 日
Hi all,
How can I convert a number to duration format of 00:00?
For example, I want to the followings:
15 to 15:00
45 to 45:00
60 to 01:00:00
240 to 04:00:00
Thanks.

採用された回答

Guillaume
Guillaume 2019 年 8 月 27 日
demodata = [15; 45; 60; 240];
d = minutes(demodata);
d.Format = 'hh:mm:ss'
displays:
d =
4×1 duration array
00:15:00
00:45:00
01:00:00
04:00:00

その他の回答 (1 件)

Shubham Gupta
Shubham Gupta 2019 年 8 月 27 日
編集済み: Shubham Gupta 2019 年 8 月 27 日
Use datestr() to convert number to time
x = 15;
if x>=60
out = datestr(x/24/60,'HH:MM:SS')
else
out = datestr(x/24/60,'MM:SS')
end
I hope it helps !

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by