Error: NSGA-II algorithm for the cost and satisfaction objectives
7 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Respuestas (1)
Arnav
el 8 de Nov. de 2024 a las 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 comentarios
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!