I am trying to form a conditional loop that shows the growth of money, I put in $1000 every year and it grows by 85 for ten years but keep returning one value
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Matthew
el 19 de Abr. de 2024
I am trying to make it add $1000 every year and have an 8% return over 10 years but don't know how to access my previous value in my loop
money=1000;
supersaver=1000;
y=zeros(1,10);
for i=1:10
y(i)=(money+supersaver)*1.08
end
0 comentarios
Respuesta aceptada
Torsten
el 19 de Abr. de 2024
Editada: Torsten
el 19 de Abr. de 2024
money = zeros(10,1);
supersaver = 1000;
Return = 0.08;
money(1) = supersaver*(1+Return); % Money at end of year 1
for i = 2:10
money(i) = (supersaver + money(i-1))*(1+Return); % Money at end of year i
end
format longEng
money
0 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Install Products en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!