Info

Questa domanda è chiusa. Riaprila per modificarla o per rispondere.

Basic Looping Help Please?

1 visualizzazione (ultimi 30 giorni)
Darren
Darren il 19 Set 2014
Chiuso: MATLAB Answer Bot il 20 Ago 2021
Problem: Need to reach a downpayment of $50,000. Have 2,000 dollars already. ROI is 4%. Inflation is 2.5%. Need to calculate present value and future value of money saved and need to figure out how long both will take in years. So Future Value = (Money Saved*ROI) + Money added. I add $10,000 a year. So the "money saved" is what changes every year. Present Value = Future Value/(1+inflation)^years
Heres my code I currently have for that portion:
for i = 1:length(years)
if (amount_start_with < amount_needed_present_dollars);
future_value(i) = amount_start_with*(1/ROI*100) + amount_add_every_year;
present_value = future_value./(1 + inflation).^years
end
end
So I have 2 weeks experience with matlab so I have little idea as to what I'm doing. I defined the input variables as the amount_start_with, etc. I keep getting errors that I'm not defining "years". The problem is I don't know how many years it will take to reach the goal for the downpayment. I also got an error about matrix dimensions. Also should the "years" in my present_value equation be defined as the same as I have in the first line? Please Help

Risposte (1)

Rick Rosson
Rick Rosson il 19 Set 2014
Try using a while loop instead of a for loop.

Questa domanda è chiusa.

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by