Need help with for loop
1 次查看(过去 30 天)
显示 更早的评论
hi. i'm trying something simple but i lilterally don't get it why it doesn't works in MATLAB. (i'm not familiar with using MATLAB, but C/C++)
so, here's my code :
for i = 1 : n-4
for j = j+1 : n-4
for k = j+1 : n-4
for l = k+1 : n-4
%% other codes
end
end
end
end
i've try to excute the code above, but the second for loop didn't excute. (it just slipped away)
i know it works on C/C++ or Python. so, what did i missed?
is it because MATLAB wouldn't allow this kind of for loops or something else?
3 个评论
回答(1 个)
jedak
2022-5-20
Where you define you variable j?
If you define a loop as:
for j=a:b
(code)
end
a should be <= b
if not the loop is not going to work.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Logical 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!