필터 지우기
필터 지우기

if i have tow matrix how to crossover of them ?

조회 수: 3 (최근 30일)
Firas Al-Kharabsheh
Firas Al-Kharabsheh 2016년 4월 25일
댓글: Firas Al-Kharabsheh 2016년 4월 25일
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 ]

채택된 답변

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

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Genetic Algorithm에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by