%% Find the Bond Key Rate Duration Given the Zero Curve
% This example shows how to compute the key rate duration of a bond for key rate times of 2, 5, 10, and 30 years.

ZeroRates = [0.0476 .0466 .0465 .0468 .0473 .0478 ...
.0493 .0539 .0572 .0553 .0530]';

ZeroDates = daysadd('31-Dec-1998',[30 360 360*2 360*3 360*5 ...
360*7 360*10 360*15 360*20 360*25 360*30],1);

ZeroData = [ZeroDates ZeroRates];

krdur = bndkrdur(ZeroData,.0525,'12/31/1998',...
'11/15/2028','KeyRates',[2 5 10 30])

% Copyright 2015 The MathWorks, Inc.