好吧,我已经尝试这个问题超过 10 个小时了,但不知道如何解决这个问题,这里是:
Imagine that you are a proud new parent. You decide to start a college savings plan for your child, hoping to have enough in 18 years. Suppose that your folks give you $1000 to get started and that each month you can contribute $100. Suppose also that the interest rate is 6% per year compounded monthly, which is equivalent to 0.5% each month. Because of interest payments and your contribution, each month your balance will increase in accordance with the formula:
New Balance = Old Balance + interest + your contribution
Use a for loop to find the amount in the savings account each month for the next 18 years. (Create a vector of values.) Plot the amount in the account as a function of time.
我所困惑的部分是如何将新的天平重新插入方程 216 次(18 年)。我能够获得第一个每月余额,但不知道如何让循环继续剩余的 215 个月。 有小费吗?谢谢!
最佳答案
忘掉旧的和新的。基本思想是这样的:
Balance = 0;
for j=1:216,
Balance = Balance + interest + your contribution;
end
关于matlab - 如何将 for 循环的值发送回循环,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8073950/