transformation between different time representations
이전 댓글 표시
Hello, I have a vector whose elements are of the kind "hhmmss", representing different times of a certain day. I have to transform them in a decimal number 0.xyzt... representing the fraction of day corresponding to that time. How can I do? Thanks, Elena.
답변 (2개)
Azzi Abdelmalek
2012년 12월 13일
편집: Azzi Abdelmalek
2012년 12월 13일
out=datenum(date)
Also look at datestr, datevec
Peter Perkins
2012년 12월 13일
0 개 추천
Elena, if your times are strings, then Azzi's suggestion is the way to go. But if your times are numeric (53221, say, as opposed to '053221'), then you'll need to successively divide by 100 and use floor to get the hours, then similarly get minutes, and the seconds, and then multiply those by 1/24, 1/(24*60), and 1/(24*60*60) and add that up.
Hope this helps.
카테고리
도움말 센터 및 File Exchange에서 MATLAB에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!