Products & Services Solutions Academia Support User Community Company

Learn more about MATLAB   

getabstime (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. To define the time vector relative to a calendar date, set the TimeInfo.StartDate property of the timeseries object. When the TimeInfo.StartDate format is a valid datestr format, the output strings from getabstime have the same format.

Examples

The following example shows how to extract a time vector as a cell array of date strings from a timeseries object.

  1. 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.

  2. Set the StartDate property.

    ts.TimeInfo.StartDate = '10/27/2005 07:05:36';
    
  3. Extract the time vector.

    getabstime(ts)
    
    ans = 
    
        '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'
    
  4. Change the date-string format of the time vector.

    ts.TimeInfo.Format = 'mm/dd/yy'
    
  5. Extract the time vector with the new date-string format.

    getabstime(ts)
    
    ans = 
    
        '10/27/05'
        '10/27/05'
        '10/27/05'
        '10/27/05'
        '10/27/05'
    

See Also

setabstime (timeseries), timeseries, tsprops

  


Recommended Products

Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.

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