Question

Part 2 (matlab) Functions Many of you will have some form of a loan during your...

Part 2 (matlab)

Functions Many of you will have some form of a loan during your lifetime, either a student loan, mortgage, credit card debt, or other loan. If you never do have a loan, great! But you may have to calculate a payment for someone else, such as the company you work for. Such a loan will have a principal amount (called the present value), an interest rate, and a number of periods for the loan. The formula to calculate the payment P required to pay off a loan of value PV over n periods at r interest rate is

?? = ??(????) 1 ? (1 + ??)???

For example, if you have a $20,000 loan (PV = 20000) at a 5% annual percentage rate, to be paid monthly over 10 years, the rate r would be 0.05/12 (monthly rate) and the number of periods n would be 12*10 = 120. The payment would then be $212.13 per month (with a slightly larger payment at the end to take care of the tenths of a penny I truncated off).  
Please note that if n is in months, then r has to be the monthly rate. The monthly rate can be found by taking the annual percentage rate (APR) and dividing by 12.

a) Write a function payment that takes in PV, r, and n as inputs, and outputs the payment P.

b) Use the function you wrote above to create a loan amortization table. A loan amortization table will show how much principal is left after each payment and how much interest is paid with each payment. The columns should be principal paid, interest paid, cumulative principal, cumulative interest, and principal balance. So for the loan above, the amortization table would look like:

Principal Paid Interest Paid Cumulative Prin Cumulative Int    Principle Balance    

   128.80    83.33 128.80                   83.33                    19871.20

   129.33    82.80 258.13 166.13    19741.87

   129.87    82.26 388.01 248.39 19611.99      

   130.41 81.72    518.42 330.10    19481.58      

Homework Answers

Answer #1

a)

%matlab code

clc;
close all;
clear all;

Principle = 20000;
rate = 5; %annual
no_installments = 10 %years
Payment = Emi(Principle,rate/(12*100),no_installments*12)

%end

Emi function Emi.m code

%start

function EMI = Emi(p,r,n)

EMI = (p * r * (1+r)^n)/(((1+r)^n)-1);

%end

Result:

Payment = 212.1310

b)

clc;
close all;
clear all;

P = 20000;
rate = .05/12;  
no_installments = 10*12;


[Principal, Interest, Balance, Payment] = amortize(rate, ...
no_installments, P)
fp = fopen('loan.txt','w');
fprintf(fp,'Principle paid\n');
fprintf(fp,'%f\n',Principal);
fprintf(fp,'Interest paid\n');
fprintf(fp,'%f\n',Interest);
fprintf(fp,'cumu prin\n');
fprintf(fp,'%f\n',cumsum(Principal));
fprintf(fp,'cumu in\n');
fprintf(fp,'%f\n',cumsum(Interest));
fprintf(fp,'balance\n');
fprintf(fp,'%f\n',Balance);
fclose(fp)

%end of code

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
You take out a 20-year loan in the amount of $450,000 at a 4 percent annual...
You take out a 20-year loan in the amount of $450,000 at a 4 percent annual rate. The loan is to be paid off by equal monthly installments over 20 years. Draw an amortization table showing the beginning balance, total payment, principal repayment, interest payment and ending balance for each month. How much is the total interest payment for the first four months? (show only four months on the table).
You have just sold your house for $1,000,000 in cash. Your mortgage was originally a 30-year...
You have just sold your house for $1,000,000 in cash. Your mortgage was originally a 30-year mortgage with monthly payments and an initial balance of $800,000. The mortgage is currently exactly 18½ years old, and you have just made a payment. If the interest rate on the mortgage is 5.25% (APR), how much cash will you have from the sale once you pay off the mortgage? Sale price $        1,000,000 Initial balance $           800,000 Number of years                        30 Periods...
Suppose you decide to purchase a $150,000 home using an inheritance of $20,000 as your down...
Suppose you decide to purchase a $150,000 home using an inheritance of $20,000 as your down payment. A down payment is subtracted from the total cost of the home and therefore you owe $130,000. To pay for this amount you will need a loan, so $130,000 is the principal on your loan. Suppose the interest rate on a 30 year mortgage is 4.75%. What will your monthly payment be? How much will you pay on the loan if you pay...
2. Suppose you borrow $20,000 at an 18 percent simple interest but must repay your loan...
2. Suppose you borrow $20,000 at an 18 percent simple interest but must repay your loan in 12 equal monthly payments. a. Find the APR for this loan. b. What is the corresponding EAR? 3. Suppose you deposit $20,000 in a savings account. After 210 days, you withdraw your funds. If the bank paid you $340 in interest for the 210-day period, what is your APY? 4. Suppose that the house of your dreams costs $1,200,000. You manage to scrap...
Prepare an amortization schedule for a seven year loan of $90,000. The interest rate is 4%...
Prepare an amortization schedule for a seven year loan of $90,000. The interest rate is 4% per year, and the loan calls for equal annual payments (see example in book, do not use the monthly amortization schedule from Canvas). Using the information from the amortization schedule (which you must include with your answers), please answer the following questions. A. How much total interest is paid over the life of the loan? B. How much interest will be paid during the...
You take out a 15-year loan amount in the amount of $300,000 at a 7% rate...
You take out a 15-year loan amount in the amount of $300,000 at a 7% rate annually. The loan is to be paid off by equally monthly installments over 15 years. Draw an amortization table showing the beginning balance, total payment, principle repayment, interest payment, and ending balance for each month. How much is the total interest payment for the 5 months? (Show only 5 months on the table) ***Please show all work***
You borrow $10,000 on January 1 and agree to pay off the loan with 10 annual...
You borrow $10,000 on January 1 and agree to pay off the loan with 10 annual end-of-year payments. Your annual effective interest rate is 5%. Complete the loan amortization table shown below for payment number 5 and payment number 6. Payment number    Payment Amount    Principal    Interest Loan Balance After Payment 5 6
you purchased a car for $120,000 which will paid in equal monthly payments of $1576.1 over...
you purchased a car for $120,000 which will paid in equal monthly payments of $1576.1 over 12 years. The annual interest rate you are charged is 12%.             a. How much of your second monthly payment will go the repayment of1) principal. 2) interest (use an amortization schedule or table).             b. what will the remaining balance be on the loan after he makes the 40th payment (Show me the financial calculator’s inputs).
The data on a loan has been collected in the Microsoft Excel Online file below. Open...
The data on a loan has been collected in the Microsoft Excel Online file below. Open the spreadsheet and perform the required analysis to answer the questions below. Amortization schedule Loan amount to be repaid (PV) $39,000.00 Interest rate (r) 11.00% Length of loan (in years) 3 a. Setting up amortization table Formula Calculation of loan payment #N/A a. Complete an amortization schedule for a $39,000 loan to be repaid in equal installments at the end of each of the...
You have just taken out an amortized loan for $404,000. Assume that the loan will be...
You have just taken out an amortized loan for $404,000. Assume that the loan will be paid in 24 equal monthly installments of ​$18,345.62​ and that the first payment will be due 1 month from today. How much of your third monthly payment will go toward the repayment of​ principal? Fill in the worksheet below.   Month Interest Owing at End of Month​ ($) Principal Repayment​ ($) Principal Owing at End of Month​ ($) 1 2 3