How can I avoid fitness function issue in quadratic equation problem of genetic algorithm tool?
2 views (last 30 days)
Show older comments
I was trying to use genetic algorithm tool of matlab for the fitness function
function totR = objFcn(in1)
%OBJFCN
% TOTR = OBJFCN(IN1)
% This function was generated by the Symbolic Math Toolbox version 5.8.
% 22-Mar-2012 09:47:17
x1 = in1(1,:);
x2 = in1(2,:);
x3 = in1(3,:);
x4 = in1(4,:);
x5 = in1(5,:);
x6 = in1(6,:);
.......
The ga command:
[x1, fval1] = ga(@objFcn,2*N,A,b,Aeq,beq,LB,UB,[],options);
It is showing the error:
??? Attempted to access in1(2,:); index out of bounds because size(in1)=[1,100].
Error in ==> objFcn at 9
x2 = in1(2,:);
Would anybody help me in this issue? I would appreciate it.
0 Comments
Accepted Answer
Walter Roberson
on 26 Dec 2012
[x1, fval1] = ga(@(x) objFcn(x .'), 2*N, A, b, Aeq, beq, LB, UB, [], options);
More Answers (0)
See Also
Categories
Find more on Genetic Algorithm in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!