Azzera filtri
Azzera filtri

For Loop problem help

5 visualizzazioni (ultimi 30 giorni)
Michael
Michael il 4 Apr 2012
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 Commento
Wayne King
Wayne King il 4 Apr 2012
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.

Accedi per commentare.

Risposte (1)

Rick Rosson
Rick Rosson il 5 Apr 2012
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

Categorie

Scopri di più su Loops and Conditional Statements in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by