How can I convert a time vector of HH:SS to a decimal?
조회 수: 2(최근 30일)
표시 이전 댓글
I have a vector of time in format HH:SS in a table and I want to convert it to a decimal number.
For example:
03:30 = 3.5
04:45 = 4.75
How can I do that?
Thanks.
채택된 답변
Steven Lord
2021년 8월 30일
If you have them stored as a duration array just use the hours function.
du = duration({'03:30', '04:45'}, 'InputFormat', 'hh:mm')
hours(du)
댓글 수: 0
추가 답변(1개)
Jan
2021년 8월 30일
v = datetime({'03:30', '04:45'}, 'InputFormat', 'HH:mm')
hour(v) + minute(v) / 60
댓글 수: 0
참고 항목
범주
Find more on Dates and Time in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!