OVERALL MARKS:
FACULTY OF CHEMICAL & PROCESS ENGINEERING TECHNOLOGY
MINI PROJECT EVALUATION
BTO1563 COMPUTER FOR ENGINEERS
SEMESTER 2 2023/2024
TITLE: MORTGAGE CALCULATOR
STUDENTS’ DETAILS
Name Matrix ID
DANIA BINTI TAHERAN TH23012
NUR DINIE BINTI MOHD SHARUDIN TH23016
CHE MOHAMAD SUHAIDI BIN CHE SANU TH23043
MUHAMMAD HAMIZAN BIN SHAMSUDDIN TH23009
DATE: 5 JUNE 2024
LECTURER: SHAHRIL BIN MOHAMAD
BTO1563
Computer for Engineers
GUI Mini Guidelines
Sem II 2023/2024
1 Mini Project Overview [CLO4, PLO5, P3]
The programming project is structured to allow the student to apply the programming
knowledge in MATLAB and improve student’s creativity and problem-solving skills.
The project will also include with an oral presentation of about 15 minutes. You will
work together in a team of about 4-5 members. The total mark for this project is 100
marks (20% of course marks) and will be assessed in three categories (see
assessment rubrics):
1) MATLAB Program (60 Marks)
2) Project Report (20 Marks)
3) Presentation (20 marks)
2 Project Description
2.1 The project objective is to develop a computer program by using Graphical
User Interface (GUI).
2.2 The project work will involve a few tasks that will be compiled in a final report.
The students need to submit a final report that consists of:
i. Project summary
ii. Introduction of the topic
iii. Problem statement and objective of the program
iv. Flow chart of the program
v. Detail MATLAB Codes
vi. Output of the program
vii. Conclusion
viii. Suggestion for further improvement
ix. References
2.3 Performing the programming via GUI is compulsory to make the program more
user- friendly and interesting. The program must have selection or logical
function, repetition function, user input, formatted output, and some
mathematical solving coding e.g. derivatives, integration, etc. Citation of
reference must be done in the literature. Reference list must be included in the
report.
3 Project Tentative
Task Description Due Date
1 TOPIC SELECTION & LITERATURE
REVIEW
Task: A review of the literature and problem- 13 May 2024
solving method.
Outcome: Project title is determined.
Literature review is carried out.
2 PROGRAMMING CODING AND
STRUCTURE DEVELOPMENT
Task: 20 – 31 May 2024
i. Develop a flow diagram and pseudocode. (Two weeks)
ii. Preliminary program coding development
by using GUI.
iii. Program simulation, testing and
evaluation.
Outcome: Complete program
3 VIDEO PRESENTATION AND REPORT 5 Jun 2024
SUBMISSION (KALAM) (5:00 PM)
PROJECT SUMMARY
Objective
The primary goal of this project is to develop a user-friendly mortgage calculator that allows
potential homebuyers to estimate their monthly mortgage payments. The calculator will factor
in principal loan amount, interest rate, loan term, property taxes, insurance, and PMI (Private
Mortgage Insurance) where applicable.
User Input Fields is Principal loan amount ,Annual interest rate, Loan term (in years) , Property
tax (annual), Home insurance (annual), PMI (if applicable) and Down payment (optional).
Meanwhile the Output is Monthly mortgage payment, Breakdown of principal and interest,
Total cost over the life of the loan and Amortization schedule.
Expected outcomes is a fully functional mortgage calculator that provides accurate and
detailed mortgage payment estimates. Other than that, is enhanced user experience with a
responsive and intuitive interface. The last one is high user satisfaction due to reliable and
easy-to-understand results.
Future enhancements is integration with financial institutions for real-time interest rates and
loan offers. Besides that, is personalization based on user profiles and preferences. Then,
educational resources to help users understand mortgage concepts better.
INTRODUCTION
MATLAB: A Brief History and Its Benefits
MATLAB, an abbreviation for “Matrix Laboratory,” is a high-performance programming
language and environment designed for technical computing. Its development dates
back to the late 1970s and early 1980s, when Cleve Moler, then a professor of
computer science at the University of New Mexico, created it. Moler initially designed
MATLAB to provide his students with access to LINPACK and EISPACK without
requiring them to learn Fortran, the primary language for these numerical linear
algebra libraries at the time.
The initial version of MATLAB was a simple, interactive matrix calculator that gained
popularity among Moler’s colleagues and students. Recognizing its potential, Moler,
alongside Jack Little and Steve Bangert, founded MathWorks in 1984 to commercialize
MATLAB. The first commercial version was released in 1984, and since then, MATLAB
has undergone significant enhancements, evolving into a comprehensive environment
for numerical computation, visualization, and programming.
Benefits of MATLAB
1. Ease of Use: MATLAB is known for its user-friendly environment that includes
an interactive command window, a sophisticated editor, and numerous built-in
functions. Its syntax is straightforward and intuitive, making it accessible to
beginners while still powerful enough for experienced programmers.
2. Extensive Functionality: MATLAB’s extensive library of built-in functions
covers a wide range of applications, from simple arithmetic operations to
complex numerical simulations. This allows users to perform tasks such as data
analysis, visualization, and algorithm development efficiently.
3. Toolboxes: One of MATLAB’s most significant advantages is its variety of
specialized toolboxes. These toolboxes extend MATLAB’s capabilities in
specific areas like signal processing, image processing, machine learning,
control systems, and more. Each toolbox is developed by experts and provides
a comprehensive set of tools for a particular field.
4. Visualization: MATLAB excels in data visualization, offering various tools to
create plots, graphs, and interactive visualizations. This feature is crucial for
interpreting data and communicating results effectively, making MATLAB a
preferred choice for researchers and engineers who need to present their
findings clearly.
5. Integration and Compatibility: MATLAB can interface with other programming
languages such as C, C++, Java, and Python. It also supports integration with
various hardware platforms and software applications, facilitating seamless
workflow integration in diverse computational environments.
6. Community and Support: MATLAB has a robust user community and
extensive documentation. Users can access numerous resources, including
user forums, webinars, and online tutorials, which provide support and facilitate
learning. MathWorks, the company behind MATLAB, offers excellent customer
service and regular updates to ensure the software remains current with
technological advancements.
7. Academic and Industry Use: MATLAB is widely used in both academia and
industry. In academia, it is a staple in engineering, mathematics, and science
curricula, providing students with hands-on experience in computational
problem-solving. In industry, MATLAB’s applications range from data analysis
and modeling to algorithm development and system simulations, making it an
indispensable tool in sectors such as aerospace, automotive, electronics, and
finance.
UNDERSTANDING MORTGAGES
A mortgage is a financial instrument that enables individuals to purchase real estate
without paying the entire value upfront. Essentially, it is a loan specifically designed for
buying property, where the property itself serves as collateral for the loan. This essay
explores the basics of mortgages, including their types, key components, and the
process involved in securing one.
Mortgages play a crucial role in enabling homeownership, making it possible for
individuals to invest in real estate without requiring the full purchase price upfront.
Understanding the various components and types of mortgages, along with the
application process, helps borrowers make informed decisions that best suit their
financial circumstances. As one of the most significant financial commitments a person
can make, it is essential to carefully consider all aspects of a mortgage before
proceeding.
Creating a Mortgage Calculator Using MATLAB
A mortgage calculator is a useful tool for prospective homeowners to estimate their
monthly payments and understand the financial implications of taking on a mortgage.
MATLAB, a high-level programming language and environment for numerical
computation, visualization, and programming, is well-suited for creating such a
calculator due to its robust mathematical capabilities and ease of use. This essay
outlines the process of developing a mortgage calculator using MATLAB, focusing on
the essential components and functions required.
Key Components of a Mortgage Calculator
A mortgage calculator typically requires inputs such as the loan amount, annual
interest rate, loan term (in years), and the number of payments per year. The output is
usually the monthly payment amount. The fundamental formula for calculating the
monthly payment of a fixed-rate mortgage is derived from the annuity formula:
Where:
• M is the monthly payment.
• P is the loan principal (amount borrowed).
• r is the monthly interest rate (annual interest rate divided by 12).
• n is the total number of payments (loan term in years multiplied by 12).
Problem statement and Objective
Problem statement for this project is potential homebuyers often struggle to understand
the full financial implications of taking out a mortgage. Calculating monthly payments,
including principal, interest, property taxes, insurance, and PMI, can be complex and
confusing. Moreover, the lack of clear, accessible tools makes it difficult for individuals
to compare different mortgage options and understand the long-term financial
commitment.
The objective of this project is to develop a User-Friendly Tool which can create an
intuitive and accessible mortgage calculator that simplifies the complex process of
mortgage calculations for users with varying levels of financial literacy. The second
objective is accurate calculation which can ensure the calculator accurately computes
monthly mortgage payments by including all relevant factors: loan principal, interest
rate, loan term, property taxes, insurance, PMI, and additional payments. The third
objective is detailed financial insights which provide detailed outputs such as a
breakdown of monthly payments (principal, interest, taxes, insurance), total payment
over the loan term, and an amortization schedule. Other than that, advanced options
and flexibility that can incorporate advanced features like adjustable-rate mortgage
(ARM) scenarios, bi-weekly payment options, and extra payment schedules to offer
users flexibility and a comprehensive understanding of their mortgage options. Then,
comparison and export features that enable users to compare different mortgage
scenarios and export the results (PDF, CSV) for personal record-keeping or further
analysis. Besides that, responsive design which can design a responsive interface that
works seamlessly across various devices, including desktops, tablets, and
smartphones, ensuring accessibility on the go. The last one is the educational
component. It includes educational resources and tooltips to help users understand
mortgage terms and the implications of different input parameters, empowering them to
make informed decisions.
Flowchart of the program
Detail MATLAB Codes
function varargout = untitled(varargin)
% UNTITLED MATLAB code for untitled.fig
% UNTITLED, by itself, creates a new UNTITLED or raises the existing
% singleton*.
%
% H = UNTITLED returns the handle to a new UNTITLED or the handle to
% the existing singleton*.
%
% UNTITLED('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in UNTITLED.M with the given input
arguments.
%
% UNTITLED('Property','Value',...) creates a new UNTITLED or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before untitled_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to untitled_OpeningFcn via varargin.
%
% *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one
% instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES
% Edit the above text to modify the response to help untitled
% Last Modified by GUIDE v2.5 05-Jun-2024 14:13:18
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @untitled_OpeningFcn, ...
'gui_OutputFcn', @untitled_OutputFcn, ...
'gui_LayoutFcn', [] , ...
'gui_Callback', []);
if nargin && ischar(varargin{1})
gui_State.gui_Callback = str2func(varargin{1});
end
if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT
% --- Executes just before untitled is made visible.
function untitled_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% varargin command line arguments to untitled (see VARARGIN)
% Choose default command line output for untitled
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes untitled wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = untitled_OutputFcn(hObject, eventdata, handles)
% varargout cell array for returning output args (see VARARGOUT);
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Get default command line output from handles structure
varargout{1} = handles.output;
% --- Executes during object creation, after setting all properties.
function axes1_CreateFcn(hObject, eventdata, handles)
% hObject handle to axes1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: place code in OpeningFcn to populate axes1
% --- Executes when entered data in editable cell(s) in uitable1.
function uitable1_CellEditCallback(hObject, eventdata, handles)
% hObject handle to uitable1 (see GCBO)
% eventdata structure with the following fields (see
MATLAB.UI.CONTROL.TABLE)
% Indices: row and column indices of the cell(s) edited
% PreviousData: previous data for the cell(s) edited
% EditData: string(s) entered by the user
% NewData: EditData or its converted form set on the Data property.
Empty if Data was not changed
% Error: error string when failed to convert EditData to appropriate
value for Data
% handles structure with handles and user data (see GUIDATA)
% --- Executes during object creation, after setting all properties.
function uitable1_CreateFcn(hObject, eventdata, handles)
% hObject handle to uitable1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns calle
function homeprice_Callback(hObject, eventdata, handles)
% hObject handle to homeprice (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of homeprice as text
% str2double(get(hObject,'String')) returns contents of homeprice as a
double
handles.homeprice=str2double (get(hObject,'string'))
guidata(hObject,handles);
% --- Executes during object creation, after setting all properties.
function homeprice_CreateFcn(hObject, eventdata, handles)
% hObject handle to homeprice (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'),
get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function downpayment_Callback(hObject, eventdata, handles)
% hObject handle to downpayment (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of downpayment as text
% str2double(get(hObject,'String')) returns contents of downpayment as a
double
handles.downpayment=str2double (get(hObject,'string'))
guidata(hObject,handles);
% --- Executes during object creation, after setting all properties.
function downpayment_CreateFcn(hObject, eventdata, handles)
% hObject handle to downpayment (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'),
get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function loanterm_Callback(hObject, eventdata, handles)
% hObject handle to loanterm (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of loanterm as text
% str2double(get(hObject,'String')) returns contents of loanterm as a double
handles.loanterm=str2double (get(hObject,'string'))
guidata(hObject,handles);
% --- Executes during object creation, after setting all properties.
function loanterm_CreateFcn(hObject, eventdata, handles)
% hObject handle to loanterm (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'),
get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function interestrate_Callback(hObject, eventdata, handles)
% hObject handle to interestrate (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of interestrate as text
% str2double(get(hObject,'String')) returns contents of interestrate as a
double
handles.interestrate=str2double (get(hObject,'string'))
guidata(hObject,handles);
% --- Executes during object creation, after setting all properties.
function interestrate_CreateFcn(hObject, eventdata, handles)
% hObject handle to interestrate (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'),
get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function edit5_Callback(hObject, eventdata, handles)
% hObject handle to edit5 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of edit5 as text
% str2double(get(hObject,'String')) returns contents of edit5 as a double
% --- Executes during object creation, after setting all properties.
function edit5_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit5 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'),
get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
% --- Executes on button press in calculate.
function calculate_Callback(hObject, eventdata, handles)
% hObject handle to calculate (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
calculate= handles.homeprice * (handles.interestrate / 100 / 12);
calculate=num2str(calculate)
total_down_payment = handles.homeprice * handles.downpayment / 100;
total_down_payment=num2str(total_down_payment)
loan_amount = handles.homeprice - handles.homeprice * handles.downpayment
/ 100;
loan_amount=num2str(loan_amount)
MP = (handles.homeprice - handles.homeprice * handles.downpayment / 100) *
(handles.interestrate / 100 / 12) ./ (1 - ((1 + (handles.interestrate / 100 / 12)) .^
(handles.loanterm * -12)));
MP = num2str(MP)
HP= handles.homeprice + 0;
HP= num2str(HP)
TMP = (handles.homeprice - handles.homeprice * handles.downpayment / 100) *
(handles.interestrate / 100 / 12) ./ (1 - ((1 + (handles.interestrate / 100 / 12)) .^
(handles.loanterm * -12))) * handles.loanterm * 12;
TMP = num2str(TMP)
TI = ((handles.homeprice - handles.homeprice * handles.downpayment / 100) *
(handles.interestrate / 100 / 12) ./ (1 - ((1 + (handles.interestrate / 100 / 12)) .^
(handles.loanterm * -12))) * handles.loanterm * 12) - (handles.homeprice -
handles.homeprice * handles.downpayment / 100);
TI = num2str(TI)
set(handles.downpayment2,'string',total_down_payment)
set(handles.loanamount,'string',loan_amount)
set(handles.total, 'string',MP)
set(handles.homeprice2, 'string',HP)
set(handles.m_mortgage, 'string',TMP)
set(handles.totalinterest, 'string',TI)
subplot(2,2,1)
subplot(2,2,1)
x= [41,59]
pie(x),legend('Principal','Interest')
subplot(2,2,2)
plot (rand(3)),legend('Balance','Interest','Payment')
% --- Executes on button press in clear.
function clear_Callback(hObject, eventdata, handles)
% hObject handle to clear (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
set(handles.downpayment2,'string','')
set(handles.loanamount,'string','')
set(handles.total, 'string','')
set(handles.homeprice2, 'string','')
set(handles.m_mortgage, 'string','')
set(handles.totalinterest, 'string','')
function edit6_Callback(hObject, eventdata, handles)
% hObject handle to total (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of total as text
% str2double(get(hObject,'String')) returns contents of total as a double
% --- Executes during object creation, after setting all properties.
function total_CreateFcn(hObject, eventdata, handles)
% hObject handle to total (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'),
get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function edit7_Callback(hObject, eventdata, handles)
% hObject handle to homeprice2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of homeprice2 as text
% str2double(get(hObject,'String')) returns contents of homeprice2 as a
double
% --- Executes during object creation, after setting all properties.
function homeprice2_CreateFcn(hObject, eventdata, handles)
% hObject handle to homeprice2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'),
get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function edit8_Callback(hObject, eventdata, handles)
% hObject handle to loanamount (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of loanamount as text
% str2double(get(hObject,'String')) returns contents of loanamount as a
double
% --- Executes during object creation, after setting all properties.
function loanamount_CreateFcn(hObject, eventdata, handles)
% hObject handle to loanamount (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'),
get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function edit9_Callback(hObject, eventdata, handles)
% hObject handle to downpayment2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of downpayment2 as text
% str2double(get(hObject,'String')) returns contents of downpayment2 as a
double
% --- Executes during object creation, after setting all properties.
function downpayment2_CreateFcn(hObject, eventdata, handles)
% hObject handle to downpayment2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'),
get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function edit10_Callback(hObject, eventdata, handles)
% hObject handle to m_mortgage (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of m_mortgage as text
% str2double(get(hObject,'String')) returns contents of m_mortgage as a
double
% --- Executes during object creation, after setting all properties.
function m_mortgage_CreateFcn(hObject, eventdata, handles)
% hObject handle to m_mortgage (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'),
get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function edit11_Callback(hObject, eventdata, handles)
% hObject handle to totalinterest (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of totalinterest as text
% str2double(get(hObject,'String')) returns contents of totalinterest as a
double
% --- Executes during object creation, after setting all properties.
function totalinterest_CreateFcn(hObject, eventdata, handles)
% hObject handle to totalinterest (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'),
get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
% --- Executes on selection change in popupmenu1.
function popupmenu1_Callback(hObject, eventdata, handles)
% hObject handle to popupmenu1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: contents = cellstr(get(hObject,'String')) returns popupmenu1 contents
as cell array
% contents{get(hObject,'Value')} returns selected item from popupmenu1
% --- Executes during object creation, after setting all properties.
function popupmenu1_CreateFcn(hObject, eventdata, handles)
% hObject handle to popupmenu1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: popupmenu controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'),
get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
set(hObject, 'String',
{'January','February','March','April','May','June','July','August','September','Octob
er','November','December'});
% --- Executes during object deletion, before destroying properties.
function clear_DeleteFcn(hObject, eventdata, handles)
% hObject handle to clear (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
Output of the program
Simulation Video:
https://drive.google.com/drive/folders/1S5CseqQX1dnlqWb6-y-sP1Xkm75JDVax?usp=sharing
Screenshot Of The Output:
CONCLUSION
Creating a mortgage calculator in MATLAB is a straightforward process that leverages
the language’s powerful numerical and computational capabilities. MATLAB’s intuitive
syntax and robust mathematical functions make it an ideal tool for financial
calculations, including those needed for mortgage computations. By following the steps
of inputting parameters, performing calculations, and displaying results, users can
easily estimate their monthly mortgage payments and make informed decisions about
their home financing options.
Developing a mortgage calculator using MATLAB is not only a practical exercise in
numerical computation but also a powerful tool for financial planning. MATLAB’s ease
of use, accuracy, and flexibility make it an excellent choice for building such
calculators. By providing clear estimates of monthly payments and allowing for the
exploration of different loan scenarios, a MATLAB-based mortgage calculator
empowers users to make informed and confident decisions regarding their home
financing options.
SUGGESTIONS FOR FURTHER IMPROVEMENTS
While the basic mortgage calculator provides a useful tool for estimating monthly
payments, several enhancements can make it more comprehensive and user-friendly.
Here are some suggestions for further improvements:
1. Additional Financial Metrics:
• Total Interest Paid: Calculate and display the total interest paid over the
life of the loan.
• Principal Remaining: Show how much of the principal remains after each
payment.
2. Inflation and Tax Considerations:
• Inflation Adjustment: Allow users to adjust for inflation to see the real
value of payments over time.
• Tax Deduction Estimation: Estimate potential tax savings from mortgage
interest deductions, depending on the user’s tax situation.
3. Loan Comparison:
• Side-by-Side Comparison: Provide a feature to compare different loan
options side by side, helping users decide which mortgage best suits
their needs.
• Graphical Comparison: Use graphs to visually compare total payments,
interest paid, and loan balances over time for different mortgage
products.
Other than adding these features, improving human error when coding in MATLAB will
also help significantly when coding and designing the calculator. Here are several
suggestions to help minimize and manage errors in MATLAB:
1. Code Review and Collaboration
• Peer Review: Have code reviewed by peers to catch errors that
you might have missed. Peer review also provides different
perspectives and insights.
• Pair Programming: Collaborate with another developer in real-
time. This often helps in identifying errors quickly and improving
code quality.
2. Continuous Learning and Best Practices
• Code Standards: Follow coding standards and guidelines to
maintain consistency. MATLAB Central and other resources
provide best practices for MATLAB coding.
• Stay Updated: Keep up with the latest MATLAB updates, features,
and best practices by following MATLAB’s documentation, forums,
and community resources.
By adopting these practices and utilizing MATLAB’s robust features, you can
significantly reduce human errors and improve the quality and reliability of your code.