MATLAB: Using previous values to calculate next one in a for loop

for loopprevious values

Hi, I have a matlab code to calculate agitation speed in my reactor. It uses 2 previous values of Dissolved oxygen and the previous agitation speed. My question is, I know that I can't use (i-1) in order to get the previous value. So how can I do it? Should I use (i+1)?

Best Answer

If you begin with ‘i’ that is at least 3, and you have already defined two previous values for your variables, you can use (i-1) and (i-2).