a question on inner loops

1 次查看(过去 30 天)
Hello all,
I would like to have 2 for loops such that the outer 1 counts i=1:M and the inner one from j=1:M but j~=i. How can I program this in Matlab? In other words, I would like to have something like
if true
for i=1:M
for j=1:M && j~=i
code
end
end
end

采纳的回答

John D'Errico
John D'Errico 2016-3-7
Easy.
for j = setdiff(1:M,i)

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Loops and Conditional Statements 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by