MATLAB: How should I write the fitness function for a function(fun1) with double summation double summationfitness functiongenetic algorithm M = 8; N = 5; 5≤x(1) ≤ 20 7≤x(2) ≤ 15 0≤x(3) ≤ 1 5≤x(4) ≤ 20 7≤x(5) ≤ 15 0≤x(6) ≤ 1 fun1 = Best Answer This seems straightforward (at least to me, unless there is more to this than is posted): fcn = @(x,M,N) M*(x(1)/(x(2)+5)-x(3)) + N*(x(4)/(x(5)+5)-x(6));then with ‘M’ and ‘N’ defined in the workspace, call it as: ftns = @(x) fcn(x,M,N)If you are using the ga (genetic algorithm) function, it is straightforward to constrain the parameters. See the documentation for that. Related SolutionsMATLAB: What do three inputs mean in a Matrix x(m,n,1) It creates a (3*m x n) vertically concatenated matrix of the three ‘pages’ of the 3D matrix ‘x’. MATLAB: How to write this in MATLAB n=1:20x=3*(-1/4).^nstem(n,x) Related QuestionHow can I generate a random matrixHow to express the grey-scale image as a twodimensional matrix whose size is M1 x M2.All result is zero !Bounded Constraint
Best Answer