matlab - 如何将 for 循环的值发送回循环

标签 matlab

好吧,我已经尝试这个问题超过 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/

相关文章:

python - Python 中 corrmtx(在 MATLAB 中)的对应函数是什么?

matlab - 简单的二维元胞数组追加

具有自定义元素数量的 MATLAB 命名颜色图

matlab - 在 MATLAB 中使用双积分 (dblquad) 查找正态分布重叠。奇怪的行为

r - 如何在 R 中使用 meshgrid 函数创建两个矩阵?

matlab - MATLAB 问题中的 Parfor

matlab - 使用 MATLAB 进行滚动窗口求平均值

matlab - 如何根据给定的 CDF 计算逆高斯分布?

python - 如何在Python中获取音频文件的脉冲宽度?

matlab - 将 Matlab Simulink 模型保存为带有紧密边界框的 PDF