via repmat(mod(randperm(4),2),2,1) I created, for example,

0 1 0 1

0 1 0 1

Now I am unsuccessfully looking for a way to align the columns below to each other:

0

0

1

1

0

0

1

1

Does anyone know how to do this? Just a simple command I am missing?

In a further step, I want to randomly assign to each one (n=4) a number from 1:4 (perhaps via randperm(n)?). Same for zeros. possible result:

0 4

0 1

1 1

1 2

0 3

0 2

1 4

1 3

Any help would be greatly appreciated!

Best,

F.