Skip to Main Content Skip to Search
Product Documentation

getabstime - Class: timeseries

Extract date-string time vector into cell array

Syntax

getabstime(ts)

Description

getabstime(ts) extracts the time vector from the timeseries object ts as a cell array of date strings.

Tips

Input Arguments

ts

The timeseries object from which you want to extract the time vector.

Examples

The following example extracts a time vector as a cell array of date strings from a timeseries object.

Create a timeseries object:

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

% The default time vector for ts is [0 1 2 3 4], which starts at 0 and increases 
% in 1-second increments. The length of the time vector is equal to the length of the data.

% Set the StartDate property:

ts.TimeInfo.StartDate = '10/27/2005 07:05:36';

% Extract the time vector:

getabstime(ts)

MATLAB returns:

'27-Oct-2005 07:05:36'
'27-Oct-2005 07:05:37'
'27-Oct-2005 07:05:38'
'27-Oct-2005 07:05:39'
'27-Oct-2005 07:05:40'

Change the date-string format of the time vector, and then extract the time vector with the new date-string format:

ts.TimeInfo.Format = 'mm/dd/yy';
getabstime(ts)

MATLAB returns:

'10/27/05'
'10/27/05'
'10/27/05'
'10/27/05'
'10/27/05'

See Also

datestr | setabstime | timeseries

  


» Learn more
» Download free kit
» Get trial software

 © 1984-2012- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS