24
我总是假设使用for
循环迭代空向量与完全没有循环相同。不过,我偶然发现了这种奇怪的行为:使用for循环遍历一个空矩阵
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
结果是:
ans =
3
是否有意义,或者这是一个错误?
+1:一个好问题的好答案! –
+1对于空矩阵的意外... – bla
你的意思是'for t = t''? –