Main Content

getabstime

Convert timeseries or tscollection time vector to cell array

Description

example

tstime = getabstime(ts) returns a cell array whose elements are the dates in the time vector associated with the time series in ts. The property ts.TimeInfo.StartDate must represent a date as a character vector.

Examples

collapse all

Extract time values in a timeseries time vector as a cell array of dates and times.

Create a timeseries object with the default time vector [0 1 2 3 4].

ts = timeseries([3 6 8 0 10]);

Set the TimeInfo.StartDate property to a date character vector and display the new times associated with ts, which are in increments of 1 second.

ts.TimeInfo.StartDate = '10/27/2005';
tstime = getabstime(ts)
tstime = 5x1 cell
    {'27-Oct-2005 00:00:00'}
    {'27-Oct-2005 00:00:01'}
    {'27-Oct-2005 00:00:02'}
    {'27-Oct-2005 00:00:03'}
    {'27-Oct-2005 00:00:04'}

Input Arguments

collapse all

Input time series, specified as a timeseries or tscollection object.

Tips

  • To define the timeseries time vector relative to a calendar date, set the TimeInfo.StartDate property to a valid date character vector. Valid dates can have the following formats:

    FormatExample
    dd-mmm-yyyy HH:MM:SS01-Mar-2000 15:45:17
    dd-mmm-yyyy01-Mar-2000
    mm/dd/yy03/01/00
    mm/dd03/01
    HH:MM:SS15:45:17
    HH:MM:SS PM3:45:17 PM
    HH:MM15:45
    HH:MM PM3:45 PM
    mmm.dd,yyyy HH:MM:SSMar.01,2000 15:45:17
    mmm.dd,yyyyMar.01,2000
    mm/dd/yyyy03/01/2000

Version History

Introduced before R2006a