相关疑难解决方法(0)

使用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
Run Code Online (Sandbox Code Playgroud)

结果是:

ans =
    3
Run Code Online (Sandbox Code Playgroud)

它是否有意义,或者这是一个错误?

matlab for-loop

24
推荐指数
1
解决办法
1274
查看次数

标签 统计

for-loop ×1

matlab ×1