%% Create a LIBOR Market Model Using a RateSpec
% Create a LMM object using a RateSpec.

Settle = datenum('15-Dec-2007');
CurveTimes = [1:5 7 10 20]';
ZeroRates = [.01 .018 .024 .029 .033 .034 .035 .034]';
CurveDates = daysadd(Settle,360*CurveTimes,1);

RateSpec = intenvset('Rates',ZeroRates,'EndDates',CurveDates,'StartDate',Settle);

LMMVolFunc = @(a,t) (a(1)*t + a(2)).*exp(-a(3)*t) + a(4);
LMMVolParams = [.3 -.02 .7 .14];
  
numRates = 20;
VolFunc(1:numRates,1) = {@(t) LMMVolFunc(LMMVolParams,t)};
  
Beta = .08;
CorrFunc = @(i,j,Beta) exp(-Beta*abs(i-j));
Correlation = CorrFunc(meshgrid(1:numRates)',meshgrid(1:numRates),Beta);
  
LMM = LiborMarketModel(RateSpec,VolFunc,Correlation,'Period',1)

%
% Simulate the term structures for the specified LMM object.

[ZeroRates, ForwardRates] = simTermStructs(LMM, 10,'nTrials',100);

% Copyright 2012 The MathWorks, Inc.