How can I generate a set containing all possible combinations?

5 views (last 30 days)
Let say I want to have a 2x2 matrix and the entries are chosen from numbers 1-8 (without repetition).
How can I generate a set that contains all the possible matrices? Thanks a lot!

Answers (2)

KSSV
KSSV on 28 Mar 2019
Read about perms
  2 Comments
Thomas Lu
Thomas Lu on 28 Mar 2019
I read it and I came up with perms(combnk(1:8,4)), but the program said it exceed the sizes limit...

Sign in to comment.


Bruno Luong
Bruno Luong on 28 Mar 2019
Edited: Bruno Luong on 28 Mar 2019
A = nchoosek(1:8,4);
A = num2cell(reshape(A',2,2,[]),[1 2]);
A = A(:);
% display
A{:}
Produces 70 2x2 matrices

Categories

Find more on Matrices and Arrays in Help Center and File Exchange

Products


Release

R2018a

Community Treasure Hunt

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

Start Hunting!