Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Matlab question 2. Write two m-file functions that will allow you to compare mortgages cakculations for the monthly payment and compare mortgage with different loan

Matlab question image text in transcribed
2. Write two m-file functions that will allow you to compare mortgages cakculations for the monthly payment and compare mortgage with different loan values. The monthly payment M, is calculated using 1-2)1 Where Pis 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. 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 wi1 have to make 360 monthl for a total cost of $265647.54 Figure 2: Loan Calculator Script Input and Output Format a. Create a second m-file function called "mortgage bm will allow you to compare different loan amounts. This function will have two inputs and no outputs. The two inputs in order need to be: maximum mortgage amount (in Dollars), and interest rate (in %). You can modify your file from part a for this script. Although the function does not return any values, the function will output text to the Command Window. Your script needs to create a loan amount vector with a range of loan amounts (principal) from the maximum mortgage amount down to $50,000 less in principal in $5,000 increments. Calculate the monthly payments for both 15 and 30 year payment plans based on the varying initial amounts for the principal. An example of the truncated output is shown in Figure 3 for a maximum mortgage amount of $105000 and an interest rate of 8%.(This is example output and your function should give correct values for other inputs Principal 15 year Payment 30 year Fayment 105000 100000 $95000 $2003.43 770.45 733.7 697.08 907.87 Figure 3: Loan Calculator Table Script Input and Output Format Note: The output should continue subtracting $5000 from the principal on each new row until it has subtracted $50000 from the cost of the house. The $ on principals and payments should all line up and there should be no space between the S' and the number

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

Describe how the Commerce Clause is applied to e-commerce.

Answered: 1 week ago

Question

3. What are potential solutions?

Answered: 1 week ago