Future Bank Account Balance
Show older comments
I have to create a while loop that will calculate how much money will be in my bank account 18 years from now. I start off with $2000, the interest is 0.4%, and my contribution to the account each month is $150. I have to use a while loop to do this and have a plot to show its increase over time. This is what I have but can't seem to make it work:
oldbalance = 2000;
contribution = 150;
while i <= 216
interest = 0.4/100*oldbalance;
newbalance(i) = oldbalance(i) + interest(i) + contribution(i);
oldbalance = newbalance(i);
end
plot(1:1:216,newbalance(i))
xlabel('time,(months)');
ylabel('amount in the account in dollars');
title('Plot of amount in the account as a function of time');
Accepted Answer
More Answers (0)
Categories
Find more on Loops and Conditional Statements in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!