a question on inner loops

1 Ansicht (letzte 30 Tage)
Mnr
Mnr am 7 Mär. 2016
Beantwortet: John D'Errico am 7 Mär. 2016
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

Akzeptierte Antwort

John D'Errico
John D'Errico am 7 Mär. 2016
Easy.
for j = setdiff(1:M,i)

Weitere Antworten (0)

Kategorien

Mehr zu Loops and Conditional Statements finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by