getabstime

Time vector of a timeseries as date strings.

Category: Language Fundamentals > Data Types

Syntax

t = getabstime(ts)

Returns the absolute date string of each sample.

Description

A timeseries stores times relative to a start, in the units of TimeInfo.Units. When TimeInfo.StartDate holds a date, getabstime adds each relative time to that date. Without a start date the time vector is relative and the call raises an error.

Input arguments

ts
timeseries whose TimeInfo.StartDate is set.

Output arguments

t
Cell array of date strings, one per sample, in the form 'dd-mmm-yyyy HH:MM:SS'.

Example

Dates from a start date

ts = timeseries([1; 2; 3], [0; 1; 2]);
ts.TimeInfo.StartDate = '01-Jan-2024 00:00:00';
ts.TimeInfo.Units = 'seconds';
getabstime(ts)
Output
ans = 3×1 cell

    {'01-Jan-2024 00:00:00'}
    {'01-Jan-2024 00:00:01'}
    {'01-Jan-2024 00:00:02'}

See also

timeseries setabstime datetime datestr getsamples