This MATLAB(R) function computes the monthly payment and optionally generates an HTML representation of the mortgage amortization schedule.
The function takes four input arguments:
1. The amount borrowed (dollars)
2. The annual percentage rate (percent per year)
3. The time to maturity (years)
4. A boolean flag indicating whether to generate the HTML Report
The first input argument is required, while the other three are optional (see "Syntax" below).
The function returns one output argument: the monthly payment (in dollars per month) required to pay back the loan.
Syntax:
payment = mortgage(borrowed,apr,ttm,doReport);
payment = mortgage(borrowed,apr,ttm);
payment = mortgage(borrowed,apr);
payment = mortgage(borrowed);
The ZIP file contains two M-functions:
1. mortgage.m is the function that computes the monthly payment and amortization schedule.
2. comma.m is an external utility function that converts a numeric input argument to a comma-formatted string. For more information, please type
>> help comma
at the MATLAB Command Prompt. |