timeseries

Methods

Method Reference: timeseries.getabstime

timeseries: dates = getabstime (ts)

Return the dates of the samples as text.

dates = getabstime (ts) returns a column cell array of character vectors, the date of each sample of the series ts: its time, in TimeInfo.Units, counted from TimeInfo.StartDate. They are written in the datestr format TimeInfo.Format, or 'dd-mmm-yyyy HH:MM:SS' when that is empty; seconds are rounded to the millisecond and the rest cut off, as datestr does. A series with no samples gives {}. A series with no TimeInfo.StartDate is refused.

MATLAB uses TimeInfo.Format only when it is one of the formats its documentation lists, such as 'dd-mmm-yyyy' or 'mm/dd/yyyy', and writes the default for any other, 'yyyy-mm-dd' included; here every format is used.

See also: timeseries.setabstime, tsdata.timemetadata

Source Code: timeseries

getabstime writes the date of each sample, in TimeInfo.Format when it is set.

 ts = timeseries ([1; 2; 3], [0; 6; 12]);
 ts.TimeInfo.Units = 'hours';
 ts.TimeInfo.StartDate = '01-Mar-2024 06:00:00';
 getabstime (ts)
ans =
  3x1 cell array

    {'01-Mar-2024 06:00:00'}    
    {'01-Mar-2024 12:00:00'}    
    {'01-Mar-2024 18:00:00'}
 ts.TimeInfo.Format = 'yyyy-mm-dd HH:MM';
 getabstime (ts)
ans =
  3x1 cell array

    {'2024-03-01 06:00'}    
    {'2024-03-01 12:00'}    
    {'2024-03-01 18:00'}