lundi 19 septembre 2016

How to create a 16 x 12 matrix with numbers 1 to 4 with several restrictions (as defined in the text)?

I am confronted with a challenging task. I need to create a matrix with 16 rows and 12 columns. The matrix contains the numbers 1, 2, 3, and 4 in a pseudorandomized order. The challenge for me is to distribute the numbers in a counterbalanced way: i.e. each number has to occur in each column 4 times and in each row 3 times while the order of the numbers needs to differ across rows.
An example for a 8 x 8 matrix I created manually for a better illustration how the final result should look like.

1 2 3 4 4 3 2 1;
4 3 2 1 3 1 4 2;
3 1 4 2 2 4 1 3;
2 4 1 3 1 2 3 4;
2 1 3 4 3 2 4 1;
1 4 2 3 2 1 3 4;
4 3 1 2 1 4 2 3;
3 2 4 1 4 3 1 2;

Does someone has an idea how to approach the solution via a MATLAB code for a 16 x 12 matrix with numbers 1 to 4 with the restrictions defined above?




Aucun commentaire:

Enregistrer un commentaire