フィルターのクリア

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 Center および File ExchangeLoops and Conditional Statements についてさらに検索

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by