Interest and displaying balance until double the investment?
Mostrar comentarios más antiguos
So I am trying to write a function that will show me a balance after every year with a compound interest of 10% until the balance has reached double the initial investment.
what I have so far is
x=input('initial investment ');
b=1;
for y=x*((1.1)^b)
if y< 2*y
b=b+1;
elseif y >= 2*y
disp(y);
end
I'm pretty sure that my issue is trying to get 'b' to increase each year as so far it just stops. I also think I might have to use a while loop but I don't know how.
Respuesta aceptada
Más respuestas (1)
Roger Stafford
el 26 de Oct. de 2017
This is equivalent to evaluating
y = ceil(log(2)/log(1.1));
Categorías
Más información sobre Mathematics en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!