%% Compute the Yield to Maturity for a Cash Flow When Given a Price
% Use cfyield to compute yield to maturity for a cash flow when given a price.
% Define data for the yield curve and price.

Settle = datenum('01-Jul-2003');
Price = 98;
CFlowAmounts = [30 40 30];
CFlowDates = datenum({'15-Jul-2004', '15-Jul-2005', '15-Jul-2006'})';

%
% Compute the Yield.

 Yield = cfyield(CFlowAmounts, CFlowDates, Price, Settle)

% Copyright 2015 The MathWorks, Inc.