File Exchange

image thumbnail

All Purpose Mortgage Calculator including mortgage schedule

version (133 KB) by S B
This calculator gives you all the information you need to know while shopping for a mortgage Loan


Updated 12 Sep 2012

View Version History

View License

Editor's Note: This file was selected as MATLAB Central Pick of the Week

Please let me know if you have any problems with this calculator. I will be more than willing to answer.Type ALLMORTGAGEF to bring up the GUI. even though this is made for a 30-year mortgage loan, people can also use it to analyze a shorter loan.

Cite As

S B (2021). All Purpose Mortgage Calculator including mortgage schedule (, MATLAB Central File Exchange. Retrieved .

Comments and Ratings (9)


The inability to plot and populate the table for loans less than 25 years is due to the code that updates the Yearly Balances fields. Using simple if/then for each field fixes this:

if Loan_Period >=1
if Loan_Period >=3
if Loan_Period >=5
if Loan_Period >=10
if Loan_Period >=15
if Loan_Period >=20
if Loan_Period >=25


jp Athanas

Very nice, everything is well presented in the GUI. but could you comment more your code or just make a small description for each section....

Rob Wilson

Nice! 2 comments - you assume currency is dollars - not a major issue - a number is a number and maths works the same in all currencies. :-)
The 'spreadsheet' like section has numbers in scientific format, ie. $57,000 is shown as 5.7000e+04 which is just harder to read.
Putting in my own mortgage details and it was nearly spot on, with a slight difference in monthly payments, but within $2.
The reason - my bank (in Britain) does interest daily rather than monthly - and I think that accounts for it.
So a future wish list for this excellent tool:
1. Daily or Monthly interest calculations (maybe with an editable list of national holidays when no interest is calculated - but that's getting a bit complex)
2. What happens if you make an overpayment of $200 (or whatever) per month, how much shorter does the term get.
3. An option to put in how many months you are in to your mortgage and current balance, to see how far ahead you are of the original term - or to see what effect over-payments have from your current position.
4. An option to specify a different overpayment on a month by month level for the entire term of the loan to see what effect that has.
5. British mortgages are often 'fixed-term' for a few years, then variable, ie. fixed at 5% for 5 years, then goes to 6% for the rest of the term. That'd be nice to put in too.

This is already an excellent tool - guess my wish list would allow me to play with various over-payment strategies to see which works the best for me - but is far more than the general user would want. :-)

Bela Kovacs

It seems to me that the graph and the spreadsheet are updated only when the loan period is at least 30y. I tried to look for the section of the code which is responsible for this, but couldn't find it. Can you help me out?

Matthew Arsenault

Well done, everything all in one screen. This is exactly what i was looking for (but was afraid i would have to try to write)!

Eric Li

James Hensman

Victor Martinez

How do you open this file? What do you run it with?

MATLAB Release Compatibility
Created with R2012b
Compatible with any release
Platform Compatibility
Windows macOS Linux

Inspired: Compute PSA-benchmarked prepayment metrics

Community Treasure Hunt

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

Start Hunting!