USING MATLAB:
A simple mortgage calculator that will output the monthly payment, the remaining balance, and plot graph
function mortgage_calculator
years=10;
annual_rate=0.03; % 3% annual interest rate
house_value=100000;
downpayment=0.20; % 20% down
loan_size=house_value*(1-downpayment);
[P,In,Ba]=compute_mortgage(loan_size,annual_rate,years);
% close all
fprintf('Monthly payment: %1.2f \nTotal Interest Paid: %1.2f\n',P,sum(In));
figure;
Ps=P-In;
plot((1:len(Ps))/12,Ps/P,(1:len(In))/12,In/P);
title('Fractions of principal and interest paid at each period');
xlabel('Year');
ylabel('Fractions');
legend('Principal fraction','interest fraction');
figure;
plot((1:length(Ba))/12, Ba);
title('Remaining balance');
xlabel('Period');
ylabel('Remaining balance');
Get Answers For Free
Most questions answered within 1 hours.