getfield

Content of specific field

Syntax

fieldval = getfield(tsobj, field)
fieldval = getfield(tsobj, field, {dates})

Arguments

tsobj

Financial time series object.

field

Field name within tsobj.

dates

Date range. Dates can be expanded to include time-of-day information.

Description

getfield treats the contents of a financial times series object tsobj as fields in a structure.

fieldval = getfield(tsobj, field) returns the contents of the specified field. This is equivalent to the syntax fieldval = tsobj field.

fieldval = getfield(tsobj, field, {dates}) returns the contents of the specified field for the specified dates. dates can be individual cells of date strings or a cell of a date string range using the :: operator, such as '03/01/99::03/31/99'.

Examples

Create a financial time series object containing both date and time-of-day information:

dates = ['01-Jan-2001';'01-Jan-2001'; '02-Jan-2001'; ... 
         '02-Jan-2001'; '03-Jan-2001';'03-Jan-2001'];
times = ['11:00';'12:00';'11:00';'12:00';'11:00';'12:00'];
dates_times = cellstr([dates, repmat(' ',size(dates,1),1),... 
times]);
AnFts = fints(dates_times,[(1:4)'; nan; 6],{'Data1'},1,...     
              'Yet Another Financial Time Series')
AnFts = 
 
    desc:  Yet Another Financial Time Series
    freq:  Daily (1)

    'dates:  (6)'    'times:  (6)'    'Data1:  (6)'
    '01-Jan-2001'    '11:00'          [          1]
    '     "     '    '12:00'          [          2]
    '02-Jan-2001'    '11:00'          [          3]
    '     "     '    '12:00'          [          4]
    '03-Jan-2001'    '11:00'          [        NaN]
    '     "     '    '12:00'          [          6]

Example 1. Get the contents of the times field in AnFts:

F = datestr(getfield(AnFts, 'times'))
F =

11:00 AM
12:00 PM
11:00 AM
12:00 PM
11:00 AM
12:00 PM

Example 2. Extract the contents of specific data fields within AnFts:

FF = getfield(AnFts,'Data1',...
             '01-Jan-2001 12:00::02-Jan-2001 12:00')
FF =

     2
     3
     4
Was this topic helpful?