Future Bank Account Balance
Afficher commentaires plus anciens
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');
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Loops and Conditional Statements dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!