Financial Time Series Toolbox | ![]() ![]() |
Object to Matrix Conversion
The function fts2mtx
extracts the dates and/or the data series values from an object and places them into a vector or a matrix. The default behavior extracts just the values into a vector or a matrix. Look at the next example:
srs2_vec = fts2mtx(myfts.series2) srs2_vec = 0.9323 0.5608 1.5989 3.6682 5.1284 0.4952 2.2417 0.3579 3.6492 1.0150 1.2445 5.5466 0.1251 1.1195 0.3374...
If you want to include the dates in the output matrix, provide a second input argument and set it to 1
. This results in a matrix whose first column is a vector of serial date numbers:
format long g srs2_mtx = fts2mtx(myfts.series2, 1) srs2_mtx = 730251 0.932251754559576 730252 0.560845677519876 730253 1.59888712183914 730254 3.6681500883527 730255 5.12842215360269 730256 0.49519254119977 730257 2.24174134286213 730258 0.357918065917634 730259 3.64915665824198 730260 1.01504236943148 730261 1.24446420606078 730262 5.54661849025711 730263 0.12507959735904 730264 1.11953883096805 730265 0.337398214166607
The vector srs2_vec
contains just series2
values. The matrix srs2_mtx
contains dates in the first column and the values of the series2
data series in the second. Dates in the first column are in serial date format. Serial date format is a representation of the date string format (for example, serial date = 1 is equivalent to 01-Jan-0000). (The serial date vector may include time-of-day information.)
The long g
display format displays the numbers without exponentiation. (To revert to the default display format, use format short
. See the format
command in the MATLAB documentation for a description of MATLAB display formats.) Remember that both the vector and the matrix have 101 rows of data as in the original object myfts
but are shown truncated here.
![]() | Data Extraction | Indexing a Financial Time Series Object | ![]() |