I have wrote a code for my home mortgage calculations. The code pretty much runs a simulation on how sooner I would get down with my outstanding principal balance given an additional amount paid each month? I have used a while loop until my principal balance is greater than 0. My counter is the months. So I would like to know how I can plot the counter (months) and the outstanding balance each iteration?
Here is the code:
function out1 = mortgage(outstanding,interestrate,additional)p = outstanding;i = interestrate./100;escrow = 2339.10./12;payment = 1268.85;out1=[];counter=1;counter1=1;while p>0 interest = (p.*i)./12; principal = payment-interest-escrow; tp = principal+interest+escrow; if counter1==12 p=p-tp-additional-31.25-1268.85; counter1=1; counter=counter+1; else p = p-tp-additional-31.25; counter = counter+1; counter1=counter1+1; end out1=counter;end
Best Answer