%% Price Swaption for LIBOR Market Model Using the Rebonato Formula
% Define the input maturity and tenor for a LIBOR Market Model (LMM) specified by the cell array of volatility function handles, and a correlation matrix for the LMM.

Settle = datenum('11-Aug-2004');
  
% Zero Curve
CurveTimes = (1:10)';
CurveDates = daysadd(Settle,360*CurveTimes,1);
  
ZeroRates = [0.03 0.033 0.036 0.038 0.04 0.042 0.043 0.044 0.045 0.046]';
  
% Construct an IRCurve
irdc = IRDataCurve('Zero',Settle,CurveDates,ZeroRates);
  
LMMVolFunc = @(a,t) (a(1)*t + a(2)).*exp(-a(3)*t) + a(4);
LMMVolParams = [.3 -.02 .7 .14];
  
numRates = length(ZeroRates);
VolFunc(1:numRates-1) = {@(t) LMMVolFunc(LMMVolParams,t)};
  
Beta = .08;
CorrFunc = @(i,j,Beta) exp(-Beta*abs(i-j));
CorrMat = CorrFunc(meshgrid(1:numRates-1)',meshgrid(1:numRates-1),Beta);
  
ExerciseDate = datenum('11-Aug-2009');
Maturity = daysadd(ExerciseDate,360*[3;4],1);
  
Vol = blackvolbyrebonato(irdc,VolFunc,CorrMat,ExerciseDate,Maturity,'Period',1)

% Copyright 2015 The MathWorks, Inc.