MATLAB Answers

Problem in crossover of parents

6 views (last 30 days)
Mary Shah
Mary Shah on 7 Sep 2019
Edited: Mary Shah on 8 Sep 2019
I want to cross over 2 parents at point 3.
parent1=1011
parent2=1100
child=1010
i want the child to take the first 3 bits from parent1 and the last bit from parent2. i wrote this code but it says that index exceeds number of array elements.
CrossoverIndex =randi([1 3]);
child= [parent1(1:CrossoverIndex) parent2(CrossoverIndex+1:end)];
can someone please guide me?

  0 Comments

Sign in to comment.

Answers (0)

Sign in to answer this question.

Tags