Random number of nested for loops
Ältere Kommentare anzeigen
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 Kommentare
Mischa Kim
am 27 Feb. 2015
Hadi, maybe there's better ways to go about solving your problem. What exactly do you need your loops to do?
hadi
am 27 Feb. 2015
Javier Vicente
am 27 Feb. 2015
Hi Hadi.
Check nchoosek function. Maybe works for you.
hadi
am 27 Feb. 2015
Akzeptierte Antwort
Weitere Antworten (0)
Kategorien
Mehr zu Loops and Conditional Statements finden Sie in Hilfe-Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!