Compound Interest with monthly Contributions, Unable to vectorize.
古いコメントを表示
Hello, I would like help with vectorizing this code so that I can plot the answer. I have been able to get individual answers for each month, however, I cannot write this function in terms of months, so thats why I can not get my answer into a vector. Here's what I have so far.
%
New_balance=1000
for month=[0:18*12]
New_balance=New_balance*1.005+100
end
It is monthly interest of .5% for 18 years with 100 every month and an initial $1000. I want to be able to plot(months,New_balance), including the 0th month of $1000. Thank You.
採用された回答
その他の回答 (3 件)
C.J. Harris
2012 年 11 月 13 日
You don't even need to vectorise, just calculate the answer directly. The answer below is slightly lower than your answer. But in your calculation you appear to accrue interest in month zero (time of deposit).
P = 100;
i = 0.005;
A = 1000;
n = 18*12;
FV1 = ( (1 + i)^ n ) * A;
FV2 = P * ( ( (1 + i)^n - 1) / i );
FV = FV1 + FV2;
Alex
2012 年 11 月 13 日
0 投票
You could try a 1-pole IIR filter.
Oleg Komarov
2012 年 11 月 13 日
n = 18*12; % number of periods
i = 0.005; % per period interest
I = 1000; % initial investment
CF = 100; % recurrent cash flow
s = (1 + i).^(0:n); % compounding factor
capital = I*s + [0 cumsum(CF*s(1:end-1))];
plot(0:n,capital)
カテゴリ
ヘルプ センター および File Exchange で Biomechanics についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!