How to Convert this time series data to YYYY-MM-DD HH:MM format
9 ビュー (過去 30 日間)
古いコメントを表示
Dear expert,
I want to convert time series data I have in the form of hhmm and want tot convert to hh:mm format. Here is how the data looks like
![addd.JPG](https://www.mathworks.com/matlabcentral/answers/uploaded_files/227712/addd.jpeg)
I want to cobine the 3 columns. First is year. 2nd is no of day from 1st jan. 3rd is HHMM. I want YYYY-MM-DD HH:MM or something similar.
0 件のコメント
回答 (2 件)
dpb
2019 年 7 月 5 日
編集済み: dpb
2019 年 7 月 6 日
dt=datetime(Year,1,day,fix(time/100),mod(time,100),0);
ADDENDUM:
Using Star's array...
A = [2019 137 1650; 2019 144 1740];
Year=A(:,1);day=A(:,2);time=A(:,3);
dt=datetime(Year,1,day,fix(time/100),mod(time,100),0);
>> dt
dt =
2×1 datetime array
17-May-2019 16:50:00
24-May-2019 17:40:00
>>
And, of course, you don't need to make the intermediate variables, just pass the subarrays.
0 件のコメント
Star Strider
2019 年 7 月 5 日
Try this:
A = [2019 137 1650; 2019 144 1740]; % Two Sample Rows
S = num2str(A); % Strings
DT = datetime(S, 'InputFormat','uuuu DDD HHmm', 'Format','yyyy-MM-dd HH:mm') % Convert To ‘datetime’
producing:
DT =
2×1 datetime array
2019-05-17 16:50
2019-05-24 17:40
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Dates and Time についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!