I need help for calculating mortgage for a homework problem

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 Commenti

Well, of course, once we've done the hard main part for you, calling plot() is trivial. What is the formula? Can't you do a little more, knowing the formula? I think you should make some more effort. It's not that hard.
I would say the problem is poorly worded. You can't specify principle and interest and payment and in general expect that everything will work out. You only get to pick two of those and then the other one gets calculated from them, unless you are willing to have non-zero principle left at the end.
This is all I am given to try and solve it
I am sorry for the trouble and the confusion. I ended up working on it a little this morning and afternoon and got it.

Accedi per commentare.

 Risposta accettata

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 Commento

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!!!

Accedi per commentare.

Più risposte (1)

James Tursa
James Tursa il 18 Nov 2020
Modificato: James Tursa il 18 Nov 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.

Categorie

Scopri di più su Mathematics in Centro assistenza e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by