Main Content

fts2mat

Convert to matrix

fts2mat is not recommended. Use timetable instead. For more information, see Convert Financial Time Series Objects fints to Timetables.

Description

example

tsmat = fts2mat(tsobj) takes the data series in the financial time series object tsobj and puts them into the matrix tsmat as columns. The order of the columns is the same as the order of the data series in the object tsobj.

example

tsmat = fts2mat(tsobj,datesflag) specifies whether you want the dates vector included. The dates vector is the first column. The dates are represented as serial date numbers. Dates can include time-of-day information.

example

tsmat = fts2mat(tsobj,seriesnames) extracts the data series named in seriesnames and puts its values into tsmat. The seriesnames argument can be a cell array of character vectors.

example

tsmat = fts2mat(tsobj,datesflag,seriesnames) puts into tsmat the specific data series named in seriesnames. The datesflag argument must be specified. If datesflag is set to 1, the dates vector is included. If you specify an empty matrix ([]) for datesflag, the default behavior is adopted.

Examples

collapse all

  1. Create a fints object.

    dates_and_times = (now:now+5)'
    dates_and_times =
    
       1.0e+05 *
    
        7.3840
        7.3840
        7.3840
        7.3841
        7.3841
        7.3841
    
     f = fints(dates_and_times, randn(6,1))
    Warning: FINTS is not recommended. Use TIMETABLE instead. For more information, see Convert Financial Time Series Objects (fints) to Timetables. 
    > In fints (line 169) 
    f = 
     
        desc:  (none)
        freq:  Unknown (0)
    
        {'dates:  (6)'}    {'times:  (6)'}    {'series1:  (6)'}
        {'03-Sep-2021'}    {'13:02'      }    {[      -0.7648]}
        {'04-Sep-2021'}    {'13:02'      }    {[      -1.4023]}
        {'05-Sep-2021'}    {'13:02'      }    {[      -1.4224]}
        {'06-Sep-2021'}    {'13:02'      }    {[       0.4882]}
        {'07-Sep-2021'}    {'13:02'      }    {[      -0.1774]}
        {'08-Sep-2021'}    {'13:02'      }    {[      -0.1961]}
  2. Convert the fints object to a matrix using fts2mat.

    tsmat = fts2mat(f,1)
    Warning: FINTS is not recommended. Use TIMETABLE instead. For more information, see Convert Financial Time Series Objects (fints) to Timetables. 
    > In fints/fts2mat (line 33) 
    
    tsmat =
    
       1.0e+05 *
    
        7.3840   -0.0000
        7.3840   -0.0000
        7.3840   -0.0000
        7.3841    0.0000
        7.3841   -0.0000
        7.3841   -0.0000

Input Arguments

collapse all

Financial time series object, specified as a fints object.

Data Types: object

Specifies inclusion of dates vector, specified as a logical:

  • 0 — Excludes dates.

  • 1 — Includes dates vector

Data Types: logical

Data series included in matrix, specified as a character vector or cell array of character vectors.

Data Types: char | cell

Output Arguments

collapse all

Matrix, returned as a matrix as columns. The order of the columns is identical to the order of the data series in the input object tsobj.

Version History

Introduced before R2006a