Question: The monthly payment M, is calculated using: = ( /12 ) / 1 (1 + /12 )^ 12 Where P is the principal loan amount,
The monthly payment M, is calculated using:
= ( /12 ) / 1 (1 + /12 )^ 12
Where P is the principal loan amount, r is the interest rate (in decimal form not percent form), and y is the number of years of the loan.
In Matlab, Create an m-file function called mortgage_a.m that will serve as a loan calculator (like the ones that you might find on-line). This function will have three inputs and two outputs. The three inputs in order need to be: mortgage amount (in Dollars), years to payoff loan (in years), and interest rate (in %). The outputs will be in the order returned: monthly payment and total of all payments. It should also output to the Command Window the text shown in Figure 2 for the following inputs: 150000, 30 and 4.25. (This is example output and your function should give correct values for other inputs.)
Your monthly loan payment is $737.91.
You will have to make 360 monthly payments for a total cost of $265647.54.
Figure 2: Loan Calculator Script Input and Output Format
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
