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

3 visualizzazioni (ultimi 30 giorni)
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.

Risposte (0)

Categorie

Scopri di più su Loops and Conditional Statements in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by