dimanche 17 mars 2019

Matrix Randomize with order

I have a matrix consists of 357 elements 17*21 The 357 matrix's elements are 1,2,3,4,5 and the repeating times for every one like the following way (1*50 , 2*50 , 3*86 , 4*86 , 5*85 = 357 elements) I would order this elements in the matrix regarding to one of the below options:

1-Either no similar elements at the same diagonal (or line), for example if there is '2' no other '2' would be around it.

2-Or at maximum two equal element could be at the same diagonal (or line).

A = [  1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1; 
       1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1;
       1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2;
       2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2;
       2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 3 3 3 3 3;
       3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3;
       3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3;
       3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3;
       3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 4 4 4;
       4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4;
       4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4;
       4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4;
       4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5;
       5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5;
       5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5;
       5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5;
       5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5;
     ]




Aucun commentaire:

Enregistrer un commentaire