Problem in crossover of parents

1 view (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?

Answers (0)

Categories

Find more on Migrate GUIDE Apps in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!