%% Calculate Survival Probability Based on Default Probability Curve
% Create a defprobcurve object using defprobcurve and then use survprobs to calculate the survival probability.

Settle = datetime(2017,9,20);
DefProbTimes = [calmonths(6) calyears([1 2 3 4 5 7 10 20 30])];
DefaultProbabilities = [0.005 0.007 0.01 0.015 0.026 0.04 0.077 0.093 0.15 0.20]';
DefProbDates = Settle + DefProbTimes;
 
DefaultProbCurve = defprobcurve(Settle,DefProbDates,DefaultProbabilities,'Basis',5)
SurvProbTimes = [calmonths([6 12 18])];
SurvProbDates = Settle + SurvProbTimes;
outSurvProb = survprobs(DefaultProbCurve, SurvProbDates)

% Copyright 2019 The MathWorks, Inc.