I always assumed that iterating an empty vector using a for
loop was the same as not having the loop at all. However, I stumbled upon this strange behavior:
for t = [] %// Iterate an empty 0x0 matrix
1
end
for t = ones(1, 0) %// Iterate an empty 1x0 matrix
2
end
for t = ones(0, 1) %// Iterate an empty 0x1 matrix
3
end
The result is:
ans =
3
Does it make sense, or is this a bug?