%% Compute Cash Flow Amounts and Dates, Time Factors, and Mortgage Factors for a Mortgage Portfolio
% Given a portfolio of mortgage-backed securities, use mbscfamounts to compute the cash flows and other factors from the portfolio.
% Define characteristics for a mortgage portfolio.

Settle   = datenum(['13-Jan-2000';'17-Apr-2002';'17-May-2002']);
Maturity    = datenum('1-Jan-2030');
IssueDate   = datenum('1-Jan-2000');
GrossRate   = 0.08125;
CouponRate  = [0.075; 0.07875; 0.0775];
Delay       = 14;
PrepaySpeed = 100;

%
% Use mbscfamonts to evaluate the mortgage.

[CFlowAmounts, CFlowDates, TFactors, Factors] = ... 
mbscfamounts(Settle, Maturity, IssueDate, GrossRate, ... 
CouponRate, Delay, PrepaySpeed)

% Each output is a 3-by-361 element matrix padded with NaN's wherever elements are missing.
% Copyright 2015 The MathWorks, Inc.