Random number of nested for loops
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
hadi
el 27 de Feb. de 2015
Comentada: hadi
el 27 de Feb. de 2015
Dear all,
I have the following problem: I want to input an integer number 'N', then inside the program I need to generate automatically 'N' nested for loops. For example:
*If I put N=2, I need the program by itself to make the following:
for i=0:1
for j=0:1
...
end
end
*If I put N=3, I need the program by itself to make the following:
for i=0:1
for j=0:1
for j=0:1
...
end
end
end
and so on.
Thank you in advance.
Hadi.
4 comentarios
Respuesta aceptada
Mischa Kim
el 27 de Feb. de 2015
Hadi, without any further requirements on output data type, etc., how about
myarray = dec2bin([0:2^N-1],N-1)
Más respuestas (0)
Ver también
Categorías
Más información sobre Loops and Conditional Statements en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!