Filter löschen
Filter löschen

if i have tow matrix how to crossover of them ?

3 Ansichten (letzte 30 Tage)
Firas Al-Kharabsheh
Firas Al-Kharabsheh am 25 Apr. 2016
if i have this matrix
A = [ 1 0 1 1
1 1 0 1
0 1 0 1
1 1 1 0]
B = [ 0 1 1 0
0 0 1 1
1 1 0 1
1 1 0 0]
i want to make them like that
A' = [ 1 0 1 1 1 1 0 1 0 1 0 1 1 1 1 0 ]
B' = [ 0 1 1 0 0 0 1 1 1 1 0 1 1 1 0 0 ]
then i want to randomly crossover in which every 4 element like a group
C1 = [ 1 0 1 1 0 0 1 1 0 1 0 1 1 1 0 0 ]
C2 = [ 0 1 1 0 1 1 0 1 1 1 0 1 1 1 1 0 ]
THEN I WANT TO return C1 and C2 like this
C1 = [ 1 0 1 1
0 0 1 1
0 1 0 1
1 1 0 0 ]
C2 = [ 0 1 1 0
1 1 0 1
1 1 0 1
1 1 1 0 ]

Akzeptierte Antwort

Roger Stafford
Roger Stafford am 25 Apr. 2016
R = repmat(randi([0,1],4,1),1,4);
C1 = A.*R+B.*(1-R);
C2 = A.*(1-R)+B.*R;
  1 Kommentar
Firas Al-Kharabsheh
Firas Al-Kharabsheh am 25 Apr. 2016
How can i do this many times and take the best value as a matrix ?

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Community Treasure Hunt

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

Start Hunting!

Translated by