0

if I have a chromosome =[1.01, 2.03, 4.06, 6.03, 0, 5.06, 4.12, 0, 3.03, -1, 1.12, 10.01, 4.05, 8.05, 3.07, 5.08, -1, 7.10, 8.01]; how can I separate it into segments using -1 gene and -1 will be remain in the modified gene after mutation

I need to select 2 random indices inside any segment and make inversion mutation between those indices

2
  • idx = find(chromosome==-1); c1 = chromosome(1:idx-1); c2 = chromosome(idx+1:end); Commented May 7, 2024 at 5:15
  • @magnesium not a great idea; see this question on using == for comparison. Also, c1, c2 is hardly extendable (what if there are 50 chromosomes?). Shaimaa, please see minimal reproducible example and edit your post to contain the sample output of what you'd like to achieve and also what happens with multiple -1 values in your array. Commented May 7, 2024 at 5:38

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.