subsasgn

Content assignment

Syntax

subasgn

Description

subasgn assigns content to a component within a financial time series object. subasgn supports integer indexing or date string indexing into the time series object with values assigned to the designated components. Serial date numbers cannot be used as indices. To use date string indexing, enclose the date string(s) in a pair of single quotation marks ' '.

You can use integer indexing on the object as in any other MATLAB® matrix. It will return the appropriate entry(ies) from the object.

You must specify the component to which you want to assign values. An assigned value must be either a scalar or a column vector.

Examples

Given a time series myfts with a default data series name of series1,

myfts.series1('07/01/98::07/03/98') = [1 2 3]'; 

assigns the values 1, 2, and 3 corresponding to the first three days of July, 1998.

myfts('07/01/98::07/05/98')
ans =

      desc:  Data Assignment 
      freq:  Daily (1) 

      'dates:  (5)'    'series1:  (5)'
      '01-Jul-1998'    [            1]
      '02-Jul-1998'    [            2]
      '03-Jul-1998'    [            3]
      '04-Jul-1998'    [       4561.2]
      '05-Jul-1998'    [       5612.3]

When the financial time series object contains a time-of-day specification, you can assign data to a specific time on a specific day. For example, create a financial time series object called timeday containing both dates and times:

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]);
timeday = fints(dates_times,(1:6)',{'Data1'},1,'My first FINTS')
timeday = 
 
    desc:  My first FINTS
    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'          [          5]
    '     "     '    '12:00'          [          6]

Use integer indexing to assign the value 999 to the first item in the object.

timeday(1) = 999
timeday = 
 
    desc:  My first FINTS
    freq:  Daily (1)

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

For value assignment using date strings, enclose the string in single quotation marks. If a date has multiple times, designating only the date and assigning a value results in every element of that date taking on the assigned value. For example, to assign the value 0.5 to all times-of-day on January 1, 2001, enter

timedata('01-Jan-2001') = 0.5

The result is

timedata = 
 
    desc:  My first FINTS
    freq:  Daily (1)

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

To access the individual components of the financial time series object, use the structure syntax. For example, to assign a range of data to all the data items in the series Data1, you can use

timedata.Data1 = (0: .1 : .5)'
timedata = 
 
    desc:  My first FINTS
    freq:  Daily (1)

    'dates:  (6)'    'times:  (6)'    'Data1:  (6)'
    '01-Jan-2001'    '11:00'          [          0]
    '     "     '    '12:00'          [     0.1000]
    '02-Jan-2001'    '11:00'          [     0.2000]
    '     "     '    '12:00'          [     0.3000]
    '03-Jan-2001'    '11:00'          [     0.4000]
    '     "     '    '12:00'          [     0.5000]

See Also

|

Was this topic helpful?