%% Compute the Cash Flow of Principal, Interest, and Prepayment of a Pass-Through Security
% This example shows how to compute the cash flows and balances of a 3-month old mortgage pool with original term of 360 months, assuming a prepayment speed of 100.

OriginalBalance = 100000;
GrossRate = 0.08125;
OriginalTerm = 360;
TermRemaining = 357;
PrepaySpeed = 100;

[Balance, Payment, Principal, Interest, Prepayment] =... 
mbspassthrough(OriginalBalance, GrossRate, OriginalTerm,... 
TermRemaining, PrepaySpeed)

% Copyright 2015 The MathWorks, Inc.