Info

Cette question est clôturée. Rouvrir pour modifier ou répondre.

HOW TO RESOLVE "index exceeds matrix dimensions matlab"?

2 vues (au cours des 30 derniers jours)
naidu talada
naidu talada le 24 Juin 2017
Clôturé : MATLAB Answer Bot le 20 Août 2021
??? Index exceeds matrix dimensions.
Error in ==> GA at 191
firstKids(masks)=secondParents(masks);
-------------------------------------------------
reprodIndices=rand(popSize/2,1)<1-probCrossover; masks(reprodIndices,:)=false; firstKids=firstParents; firstKids(masks)=secondParents(masks); secondKids=secondParents; secondKids(masks)=firstParents(masks); pop=[firstKids; secondKids];

Réponses (1)

Walter Roberson
Walter Roberson le 24 Juin 2017
You must have initialized masks before this code or else the assignment of false would have ended up with an all-false matrix. But we do not know what size you initialized to or how that size compares to the your Parents matrices.

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by