function [mp,moperc] = mortpmt(price,dwnpmt,intrate,taxrate,years) % Function that calculates the monthly mortgage payment and the percent of % gross monthly salary that it takes to pay for it. % Copyright Jay Fletcher if nargin==0 price = 0:... %lowest printed price 25e3:... %step 1e6; %highest possible price %price = 300e3; dwnpmt = 10 *1e3; %How Much Down Payment intrate = 5.6; %Interest Rate taxrate = 2.5; %Tax Rate years = 30; %Yrs on the Note gys = 30e3; %gross yearly salary (money you make before taxes) %Calculate monthly payment and percent of gys/12 mr = intrate /100 / 12; nm = years * 12; mp = (price - dwnpmt) .* mr .* (1+mr).^nm / ((1+mr).^nm - 1); mp = mp + price * taxrate/100/12; moperc = mp *100 /gys/ 12; consest = interp1(moperc,price,.28); %Conservative Estimate is 28% aggest = interp1(moperc,price,.33); %Aggressive Estimate is 33% %figure; line(moperc,price);%'Parent',handles.axes1); line(0.28,consest,'LineStyle','none',... 'Marker','o'); text(0.28,consest,... sprintf('\\leftarrow%.0f',consest/1),... 'FontSize',10); line(0.33,aggest,'LineStyle','none',... 'Marker','o'); text(0.33,aggest,... sprintf('\\leftarrow%.0f',aggest/1),... 'FontSize',10); end strTmp = sprintf('Monthly Payment =$%.2f\nPercent - %.2f',mp,moperc); %disp(strTmp); end