What is the bug in this code with Integer Genetic algorithm solver?
显示 更早的评论
Example Code:
F = [1 2 3 4 5 6 7 8 9];
H = [1 2 3 4 5 6 7 8 9];
K = [9 8 7 6 5 4 3 2 1];
S = @(x)[H(1:x(1)-1).'-K(1:x(1)-1).';
H(x(1):x(2)-1).'-K(x(1):x(2)-1).'-F(3:6).';
H(x(2):9).'-K(x(2):9).'];
A=ga(S,2,[1,-1;-1,1],[-4,4],[],[],[2,3],[8,9],[],[1,2]);
The errors that are displayed alternatively upon solving this:
Error using "-" Matrix dimensions must agree.
Subscripted assignment dimension mismatch.
Index exceeds matrix dimensions.
I dont find any examples on ga for handling array of values with indices being constrained to integers. So someone please shed some light on this.
Thanks in advance.
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Genetic Algorithm 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!