I need help for calculating mortgage for a homework problem

10 visualizaciones (últimos 30 días)
Here is the question:
If you take out a mortgage to pay for a $100,000.00 house, how much does it actually cost to make all the payments on the mortgage? Assume a 30-year mortgage at an annual interest rate of 3.92% and a monthly payment of $473.00. Use a while loop to calculate the following:
a. Amount of each monthly payment covering interest (going to change each month!)
b. Amount of each monthly payment covering principle (going to change each month!)
c. Create the following plots
i: Figure 1 – remaining principle as a function of time
ii. Figure 2 – principle and interest covered in individual payments (from a and b above) as a function of time (so two curves on one plot)
iii. Figure 3 – total principle paid off, total interest cost, and total mortgage cost as a function of time.
I need help on completing this matlab code for using a while loop. My constants so far are...
P = 100000; % Principal starting amount
M = 473; % monthly payments
i = 0.00326666; % monthly interest
Truthfully, you don't have to do the graphs for the problem, I can figure those out once the main code and while loop is completed.
Thanks in advance!!!
  4 comentarios
Jonathan Monnat
Jonathan Monnat el 18 de Nov. de 2020
This is all I am given to try and solve it
Jonathan Monnat
Jonathan Monnat el 18 de Nov. de 2020
I am sorry for the trouble and the confusion. I ended up working on it a little this morning and afternoon and got it.

Iniciar sesión para comentar.

Respuesta aceptada

Jonathan Monnat
Jonathan Monnat el 18 de Nov. de 2020
So I was able to figure out what I needed to do. This is my work...
P = 100000; % Principal starting amount
M = 473; % monthly payments
i = 0.00326666; % monthly interest
t = 360; % months for how long I pay the loan off
k = 1;
while k <= t
interest(k) = i*P(k)
payment(k) = M - interest(k)
P(k + 1) = P(k) - payment(k)
k = k + 1;
end
Now I just have to graph.
  1 comentario
Jonathan Monnat
Jonathan Monnat el 18 de Nov. de 2020
Credit to James Tursa. I just accepted mine because if anyone else needed this I did it for them. Thank you James for the start!!!

Iniciar sesión para comentar.

Más respuestas (1)

James Tursa
James Tursa el 18 de Nov. de 2020
Editada: James Tursa el 18 de Nov. de 2020
OK, so ask yourself what has to happen every month? You get charged interest and you make a payment, right? And you are told to use a while loop. So I would assume your instructor wants something like this:
k = 1;
while( P > 0 )
interest = ___; % calculate the monthly interest on P here
payment = ___; % amount you are paying this month
payment_principle = ___; % amount of payment that is used for paying down the principle
P = ___; % calculate the new principle value
% other code to save the values you will be plotting later (using index k)
k = k + 1; % increment the index
end
% plot stuff here
You fill in the blanks and then generate your plots. The k is intended to be used as an index into the vectors you will be creating to save the information you will be plotting.

Categorías

Más información sobre Loops and Conditional Statements en Help Center y File Exchange.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by