%% Stripping Caplet Volatilities from Caps with the Same Strikes
% Compute the zero curve for discounting and projecting forward rates.

ValuationDate = datenum('17-Feb-2015');
ZeroRates = [0.02 0.07 0.25 0.70 1.10 1.62]/100;
CurveDates = datemnth(ValuationDate, [0.25 0.5 1 2 3 5]*12);
ZeroCurve = IRDataCurve('Zero',ValuationDate,CurveDates,ZeroRates)

%
% Define the cap volatility data.

CapSettle = datenum('19-Feb-2015');
CapMaturity = datenum({'19-Feb-2016';'21-Feb-2017';'20-Feb-2018'; ...
    '19-Feb-2019';'19-Feb-2020'});
CapVolatility = [0.44;0.45;0.44;0.41;0.39];
CapStrike = 0.013;

%
% Strip caplet volatilities from caps with the same strike.

[CapletVols, CapletPaymentDates, CapStrikes] = capvolstrip(ZeroCurve, ...
    CapSettle, CapMaturity, CapVolatility, 'Strike', CapStrike);

PaymentDates = cellstr(datestr(CapletPaymentDates));
format;
table(PaymentDates, CapletVols, CapStrikes)

% Copyright 2012 The MathWorks, Inc.