%% Compute the Price for a Cash Flow Given Yield to Maturity Using datetime Inputs
% Use cfprice to compute the price for a cash flow given yield to maturity using datetime inputs.

Settle = datenum('01-Jul-2003');
Yield = .05;
CFAmounts = [30;40;30];
CFDates = datenum({'15-Jul-2004', '15-Jul-2005', '15-Jul-2006'});

CFDates = datetime(CFDates,'ConvertFrom','datenum','Locale','en_US');
Settle = datetime(Settle,'ConvertFrom','datenum','Locale','en_US');
Price = cfprice(CFAmounts, CFDates, Yield, Settle)

% Copyright 2012 The MathWorks, Inc.