cell array with date and time

조회 수: 6 (최근 30일)
babyelephant
babyelephant 2019년 8월 12일
댓글: dpb 2019년 8월 14일
{[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
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
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 CenterFile Exchange에서 Dates and Time에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by