Get discount factors for input dates for
and the associated
discountfactors were introduced in R2020a as part of a new
object-based framework in the Financial Instruments Toolbox™ which supports end-to-end workflows in instrument modeling and
analysis. For more information, see Get Started with Workflows Using Object-Based Framework for Pricing Financial Instruments.
Get Discount Factors for Input Dates For an
This example shows how to get discount factors for input dates for an
irfc = IRFunctionCurve('Forward',today,@(t) polyval([-0.0001 0.003 0.02],t)); getDiscountFactors(irfc, today+30:30:today+720)
ans = 24×1 0.9984 0.9967 0.9950 0.9933 0.9916 0.9899 0.9882 0.9864 0.9846 0.9829 ⋮
CurveObj — Interest-rate curve object
Interest-rate curve object, specified by using
InpDates — Input dates
datetime array | string array | date character vector
Input dates, specified as an
1 vector using a datetime
array, string array, or date character vectors. The input dates must be
Settle date of
To support existing code,
accepts serial date numbers as inputs, but they are not recommended.
F — Discount factors
Discount factors, returned as a vector.
Version HistoryIntroduced in R2008b
R2022b: Serial date numbers not recommended
getDiscountFactors supports serial date numbers,
datetime values are recommended instead. The
datetime data type provides flexible date and time
formats, storage out to nanosecond precision, and properties to account for time
zones and daylight saving time.
To convert serial date numbers or text to
datetime values, use the
datetime function. For example:
t = datetime(738427.656845093,"ConvertFrom","datenum"); y = year(t)
y = 2021
There are no plans to remove support for serial date number inputs.