how many ways to arrange numbers from 1-3?
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Ali Noori
am 13 Okt. 2015
Beantwortet: Jos (10584)
am 16 Okt. 2015
how many ways to arrange numbers from 1-3?
I want answer like this
[1,1,1]
[1,1,2]
[1,1,3]
[1,2,1]
[1,2,2]
[1,2,3]
[1,3,1]
[1,3,2]
[1,3,3]
[2,1,1]
[2,1,2]
[2,1,3]
[2,2,1]
[2,2,2]
[2,2,3]
[2,3,1]
[2,3,2]
[2,3,3]
[3,1,1]
[3,1,2]
[3,1,3]
[3,2,1]
[3,2,2]
[3,2,3]
[3,3,1]
[3,3,2]
[3,3,3]
Can you please put these values in one matrix?
0 Kommentare
Akzeptierte Antwort
Walter Roberson
am 13 Okt. 2015
[A,P,Z] = ndgrid(1:3);
[Z(:), P(:), A(:)]
2 Kommentare
Walter Roberson
am 16 Okt. 2015
Bearbeitet: Walter Roberson
am 16 Okt. 2015
N = 5;
[A{1,1:N}] = ndgrid(1:N);
Result = cell2mat( cellfun(@(V) V(:), fliplr(A), 'Uniform', 0) );
Weitere Antworten (1)
Siehe auch
Kategorien
Mehr zu Logical finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!