How to modify data vector
4 次查看(过去 30 天)
显示 更早的评论
time1=
125×1 int32 column vector
19850101
19850101
19850101
19850101
19850102
19850102
19850102
19850102
19850103
19850103
19850103
19850103
19850104
19850104
19850104
19850104
Hi everyone,
I have a vector (time1) that conain 'year', 'month' and 'day' in this format '19850101'. Is there a way to modify this format separating 'year', 'month and 'day'? Thanks.
0 个评论
回答(1 个)
Giuseppe Inghilterra
2020-2-25
Hi,
you convert to string your time vector (num2str function) and then convert it to date (datetime function), specifying input format as follow:
time1_str = num2str(time1);
time1_date = datetime(time1_str,'InputFormat','yyyyMMdd','Format','dd-MM-yyyy');
Note that you can decide output format (in my example is dd-MM-yyyy).
Hope this helps.
2 个评论
Giuseppe Inghilterra
2020-2-25
Your welcome. If solution/answer works for you, remember to mark answer as accepted.
另请参阅
类别
在 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!