The for statement makes it convenient to execute a routine repeatly while counting iterations of a loop. It looks like this:
for i = 1:5 x(i) = i^2; end
The above code works by first evaluating the expression 1:5 to produce a range of values from 1 to 5. Then the variable i is assigned the first element of the range and
x(i) = i^2;in the loop is executed once. And this process continues until there are no more elements to assign for i.
function z = AR3(a,x,n) z = x; for i = 4:(3+n) z(i) = a(1) * z(i-1) + a(2) * z(i-2) + a(3) * z(i-3); end