%% Compute Yield to Maturity for a Treasury Bond Using datetime Inputs
% This example shows how to use datetime inputs to compute the yield of a Treasury bond at three different price values.

Price = [95; 100; 105];
CouponRate = 0.05;
Settle = datetime('20-Jan-1997','Locale','en_US');
Maturity = datetime('15-Jun-2002','Locale','en_US');
Period = 2;
Basis = 0;
Yield = bndyield(Price, CouponRate, Settle,...
Maturity, Period, Basis)

% Copyright 2012 The MathWorks, Inc.