matlab present value is 1000 and the interest is 6 compounde
matlab: present value is $1000 and the interest is 6% compounded annually, how many years will it take to double your investment?
use fprintf to format the problem
Year Balance
1 $1060.00
2 $xxxx.xx
3 . . .
Solution
clc
clear all
p=1000;
r=6;
i=1;
amount=p;
while (amount<2000)
sol(i)=amount*(1+r/100);
amount=sol(i);
i=i+1;
end
fprintf(\' Year Balace\ \')
for j=1:i-1
fprintf(\' %d %.2f\ \',j,sol(j))
end
RESULT:
Year Balace
1 1060.00
2 1123.60
3 1191.02
4 1262.48
5 1338.23
6 1418.52
7 1503.63
8 1593.85
9 1689.48
10 1790.85
11 1898.30
12 2012.20
