Borrar filtros
Borrar filtros

a question on inner loops

1 visualización (últimos 30 días)
Mnr
Mnr el 7 de Mzo. de 2016
Respondida: John D'Errico el 7 de Mzo. de 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

Respuesta aceptada

John D'Errico
John D'Errico el 7 de Mzo. de 2016
Easy.
for j = setdiff(1:M,i)

Más respuestas (0)

Categorías

Más información sobre Loops and Conditional Statements en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by