Azzera filtri
Azzera filtri

a question on inner loops

1 visualizzazione (ultimi 30 giorni)
Mnr
Mnr il 7 Mar 2016
Risposto: John D'Errico il 7 Mar 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

Risposta accettata

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

Più risposte (0)

Categorie

Scopri di più su Loops and Conditional Statements in Help Center e File Exchange

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by