%% Create an HWTree
% Using the data provided, create a Hull-White volatility specification (VolSpec), rate specification (RateSpec), and tree time layout specification (TimeSpec). Then, use these specifications to create a Hull-White tree using hwtree.

Compounding = -1;
ValuationDate = '01-01-2004';
StartDate = ValuationDate;
VolDates = ['12-31-2004'; '12-31-2005'; '12-31-2006'; 
'12-31-2007'];
VolCurve = 0.01;
AlphaDates = '01-01-2008';
AlphaCurve = 0.1;
Rates = [0.0275; 0.0312; 0.0363; 0.0415];

HWVolSpec = hwvolspec(ValuationDate, VolDates, VolCurve,...  
AlphaDates, AlphaCurve);

RateSpec = intenvset('Compounding', Compounding,...
					 'ValuationDate', ValuationDate,...
					 'StartDates', ValuationDate,...
					 'EndDates', VolDates,...
					 'Rates', Rates);
 
HWTimeSpec = hwtimespec(ValuationDate, VolDates, Compounding);
HWTree = hwtree(HWVolSpec, RateSpec, HWTimeSpec)

% Use treeviewer to observe the tree you have created.
% Copyright 2012 The MathWorks, Inc.