cell array with date and time
2 次查看(过去 30 天)
显示 更早的评论
{[11-Jun-1962 00:00:00]}
{[16-Mar-1961 00:00:00]}
{[02-Jun-1934 00:00:00]}
{[02-Jun-1934 00:00:00]}
{[09-Jun-1965 00:00:00]}
{[09-Jun-1965 00:00:00]}
{[13-Apr-1955 00:00:00]}
{[13-Apr-1955 00:00:00]}
{[09-Dec-1947 00:00:00]}
I have a cell array like above.
I want to convert this to a cell array only with dates.
18 个评论
dpb
2019-8-14
That was an inadvertent INT() for FIX() , Walter. Seems in context of the reply would have been clear what was intended. Often fall into that as while ML has the the many intXX() versions, there's no generic as used to in Fortran...
dpb
2019-8-14
>> datetime(2008+5,2,29)
ans =
datetime
01-Mar-2013
>>
"+calyears()" is probably the more expected behavior for financial and date-keeping purposes.
>> which -all plus
built-in (C:\ML_R2017\toolbox\matlab\ops\@double\plus) % double method
built-in (C:\ML_R2017\toolbox\matlab\ops\@uint8\plus) % uint8 method
built-in (C:\ML_R2017\toolbox\matlab\ops\@uint16\plus) % uint16 method
...
built-in (C:\ML_R2017\toolbox\matlab\ops\@single\plus) % single method
built-in (C:\ML_R2017\toolbox\matlab\ops\@char\plus) % char method
built-in (C:\ML_R2017\toolbox\matlab\ops\@logical\plus) % logical method
plus is a built-in method % string method
C:\ML_R2017\toolbox\matlab\timefun\@duration\plus.m % duration method
C:\ML_R2017\toolbox\matlab\timefun\@calendarDuration\plus.m % calendarDuration method
C:\ML_R2017\toolbox\matlab\timefun\@datetime\plus.m % datetime method
...
>>
All three classes have methods specific to them.
The upshot is, one has to have an understanding of how things work to ensure one gets the result wanted for a particular purpose. Any of the above could conceivably be the desired result for a specific application.
The conversation has pointed out more specifics of the original point made...a datetime is a totally different animal than a datenum...
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Time Series Objects 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!