This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.


Content of specific field


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



Financial time series object.


Field name within tsobj.


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


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 character vectors or a cell of a date character vector range using the :: operator, such as '03/01/99::03/31/99'.


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),... 
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 =


Related Examples

Introduced before R2006a

Was this topic helpful?