How to use a for loop to get previous values to calculate next one

3 visualizaciones (últimos 30 días)
I am having trouble with my foor loop. I want to get the previous value to use in the next calculated value.
x(1) = A+B*(-K*cl^(k-1));
for k=0:4
x(k) = A*x(k-1) + B*(-K*cl^(k-1));
end
Error I keep getting is:
Unable to perform assignment because the indices on the left side are not compatible with the size of the right side.

Respuestas (0)

Categorías

Más información sobre Loops and Conditional Statements 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