%% Price a Bond Using the HW Tree
% Price a 4% bond using a Hull-White interest-rate tree.
% Load deriv.mat, which provides HWTree. The HWTree structure contains the time and interest-rate information needed to price the bond.

load deriv.mat;

%
% Define the bond using the required arguments. Other arguments use defaults.

CouponRate = 0.04;
Settle = '01-Jan-2004';
Maturity = '01-Jan-2006';

%
% Use bondbyhw to compute the price of the bond.

Period = 1;
Price = bondbyhw(HWTree, CouponRate, Settle, Maturity, Period)

% Copyright 2015 The MathWorks, Inc.