How to store all loop results? how can i solve this problem??
Ältere Kommentare anzeigen
i have the following loop
for i=1:4
for j=2:5
if i<j
a=i;
b=j;
ind=[a,b]
end
end
end
how can i store all results for example: a=
1 2
1 3
1 4
1 5
2 3
2 4
2 5
3 4
3 5
4 5
1 Kommentar
Stephen23
am 22 Dez. 2014
Don't do this in a loop: see Jan Simon's much improved solution to this problem.
Akzeptierte Antwort
Weitere Antworten (1)
Jan
am 21 Dez. 2014
What about:
nchoosek(1:5, 2)
Kategorien
Mehr zu Loops and Conditional Statements finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!