Effacer les filtres
Effacer les filtres

a question on inner loops

1 vue (au cours des 30 derniers jours)
Mnr
Mnr le 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

Réponse acceptée

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

Plus de réponses (0)

Catégories

En savoir plus sur Loops and Conditional Statements dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by