Syntax
As the for-loop documentation states, the for loop's syntax is:
for variable=expression do instruction, ,instruction,end
If expression
is a matrix or a row vector, variable
takes as values the values of each column of the matrix.
Your example
Your for-loop uses 7:1 as expression
, what will result in a valid but empty vector:
-->7:1
ans =
[]
The for-loop then takes each value in the vector and then finishes, but since your vector is empty it finishes directly. So it is valid syntax.
Working example
The documentation gives the following example of a working decreasing loop:
for j=4:-1:1
disp(j);
end // decreasing loop