transformation between different time representations

1 回表示 (過去 30 日間)
Elena  Cantoni
Elena Cantoni 2012 年 12 月 13 日
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
Azzi Abdelmalek 2012 年 12 月 13 日
編集済み: Azzi Abdelmalek 2012 年 12 月 13 日
out=datenum(date)
Also look at datestr, datevec

Peter Perkins
Peter Perkins 2012 年 12 月 13 日
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.

カテゴリ

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