Error: NSGA-II algorithm for the cost and satisfaction objectives
7 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
When running the main program main.m in MATLAB 2016a, the following error message keeps appearing. Please modify the code based on the error message below to ensure that the modified code runs smoothly and outputs the correct results.
"Index exceeds matrix dimensions."
Error in CalcCrowdingDistance (line 27):
d(so(i), j) = abs(cj(i+1) - cj(i-1)) / abs(cj(1) - cj(end));
Error in nsga2 (line 95):
pop = CalcCrowdingDistance(pop, F);
0 commentaires
Réponses (1)
Arnav
le 8 Nov 2024 à 6:28
The error is due to accessing the matrix cj with an index i exceeding its dimensions in line 27 of CalcCrowdingDistance.m. The index i goes from 2 to n-1.
Replacing line 12
n = numel(F{k});
with
n = numel(Costs);
fixes the error as the length of cj is the length of Costs and not F{k}.
0 commentaires
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!