How do I convert a decimal number to a time?
조회 수: 32 (최근 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.
댓글 수: 2
채택된 답변
추가 답변 (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!