For Loop problem help

5 次查看(过去 30 天)
Michael
Michael 2012-4-4
Hello, well i have a situation here, I am trying to create a for loop for a problem:
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.
I don't know if anyone will be able to help me lol but im just stuck on when i get the old balance to equal the new balance, to get that new balance to go back into the loop for the amount of time (216 months). Any help? Thanks!
  1 个评论
Wayne King
Wayne King 2012-4-4
Hi Michael, please show the code you have written so far to try and solve the problem. People here are much more likely to help with homework problems when you show what you have done.

请先登录,再进行评论。

回答(1 个)

Rick Rosson
Rick Rosson 2012-4-5
Here's a start:
N = 216;
r = 0.005;
P = zeros(N,1);
P(1) = 1000;
for k = 2:N+1
P(k) = ...
end
HTH.
Rick

类别

Help CenterFile Exchange 中查找有关 Loops and Conditional Statements 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by