How to access the 3rd element in a for loop?
古いコメントを表示
investment = 1000;
interestRate = 0.01;
months =[1:12];
for month = months
investment = investment * (1 + interestRate);
end
Displays:
investment = 1010
investment = 1020.1
investment = 1030.3
investment = 1040.6
investment = 1051.0
investment = 1061.5
investment = 1072.1
investment = 1082.9
investment = 1093.7
investment = 1104.6
investment = 1115.7
investment = 1126.8
採用された回答
その他の回答 (1 件)
investment = zeros(13,1);
investment(1) = 1000;
interestRate = 0.01;
months =[1:12];
for month = months
investment(month+1) = investment(month) * (1 + interestRate);
end
investment(4)
カテゴリ
ヘルプ センター および File Exchange で Financial Toolbox についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!