A=input('Please input the amount of load A=');
M=input('Please input the number of months M=');
R=input('Please input the monthly interest rate R=');
P=A*(R*(1+R)^M/((1+R)^M-1));
B=zeros(M,1);
Ip=B;
Pr=B
for m=1:M
if m==1
Ip(m)=A*R;
else
Ip(m)=R*B(m-1);
end
Pr(m)=P-Ip(m);
if m==1
B(m)A=Pr(m);
else
B(m)=B(m-1)-Pr(m);
end
end
format bank
disp(['Amount of your load='num2str(A)]);
disp(['Monthly interest rate='num2str(R)]);
disp(['Number of months='int2str(M)]);
disp(['Payment='num2str(P)]);
disp('');
disp(' Amortization Schedule');
disp('Payment Balance Interest Primary');
disp([[1:M]' B Ip Pr]);
format short g