Error: NSGA-II algorithm for the cost and satisfaction objectives
조회 수: 7 (최근 30일)
이전 댓글 표시
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
답변 (1개)
Arnav
2024년 11월 8일 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
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!