I am trying to form a conditional loop that shows the growth of money, I put in $1000 every year and it grows by 85 for ten years but keep returning one value

1 次查看(过去 30 天)
I am trying to make it add $1000 every year and have an 8% return over 10 years but don't know how to access my previous value in my loop
money=1000;
supersaver=1000;
y=zeros(1,10);
for i=1:10
y(i)=(money+supersaver)*1.08
end

采纳的回答

Torsten
Torsten 2024-4-19
编辑:Torsten 2024-4-19
money = zeros(10,1);
supersaver = 1000;
Return = 0.08;
money(1) = supersaver*(1+Return); % Money at end of year 1
for i = 2:10
money(i) = (supersaver + money(i-1))*(1+Return); % Money at end of year i
end
format longEng
money
money = 10x1
1.0e+00 * 1.08000000000000e+003 2.24640000000000e+003 3.50611200000000e+003 4.86660096000000e+003 6.33592903680000e+003 7.92280335974400e+003 9.63662762852352e+003 11.4875578388054e+003 13.4865624659098e+003 15.6454874631826e+003
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Install Products 的更多信息

标签

产品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by