For loop with previous result

5 visualizaciones (últimos 30 días)
Jane Smith
Jane Smith el 5 de Mzo. de 2021
Comentada: Jane Smith el 5 de Mzo. de 2021
for t=1:n
a(t)=600+10^t
b(t)=600-a(t)
end
I want that b to always taking the previous result
so, b(1)=600-a(1)
b(2)=(600-a(1))-a(2)
b(3)=(600-a(1)-a(2))-a(3)
how can i change the t

Respuesta aceptada

Mathieu NOE
Mathieu NOE el 5 de Mzo. de 2021
hello Jane
this is it :
at the k step : b(k) is 600 - sum of a from 1 to k
for t=1:n
a(t)=600+10^t;
b(t)=600-sum(a(1:t));
end

Más respuestas (0)

Categorías

Más información sobre Programming en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by