Filter löschen
Filter löschen

cell array with date and time

1 Ansicht (letzte 30 Tage)
babyelephant
babyelephant am 12 Aug. 2019
Kommentiert: dpb am 14 Aug. 2019
{[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 Kommentare
dpb
dpb am 14 Aug. 2019
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 am 14 Aug. 2019
>> 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...

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Kategorien

Mehr zu Time Series Objects finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by