%% Calculate the Previous Coupon Date on or Before Settlement
% Determine the PreviousCouponDate when using character vectors for input arguments.

PreviousCouponDate = cpndatep('14-Mar-1997', '30-Jun-2000',...  
2, 0, 0);
datestr(PreviousCouponDate)

%
% Determine the PreviousCouponDate when using datetime arrays for input arguments.

PreviousCouponDate = cpndatep(datetime('14-Mar-1997','Locale','en_US'), '30-Jun-2000',...
2, 0, 0)

%
% Determine the PreviousCouponDate when using character vectors for input arguments and the optional argument for EndMonthRule.

PreviousCouponDate = cpndatep('14-Mar-1997', '30-Jun-2000',... 
2, 0, 1);
datestr(PreviousCouponDate)

%
% Determine the PreviousCouponDate when using an input vector for Maturity.

Maturity = ['30-Apr-2000'; '31-May-2000'; '30-Jun-2000'];
PreviousCouponDate = cpndatep('14-Mar-1997', Maturity);
datestr(PreviousCouponDate)

% Copyright 2012 The MathWorks, Inc.