How do I convert a decimal number to a time?
34 次查看(过去 30 天)
显示 更早的评论
How would I convert a number such as 7.8 into a time in HH:MM? 7.8 is 7.8 hours from the start of the day, so should be shown as 07:48.
采纳的回答
更多回答(1 个)
KALYAN ACHARJYA
2018-8-2
编辑:KALYAN ACHARJYA
2018-8-2
datestr(hours(7.8),'HH:MM');
Result
>> datestr(hours(7.8),'HH:MM')
ans =
07:48
4 个评论
Sean de Wolski
2018-8-2
编辑:Sean de Wolski
2018-8-2
This is the old way to to it (before R2014b). In more recent releases, the duration approach is better.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Resizing and Reshaping Matrices 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!