15,947,785 members

What I have tried:function t=strength(x) t = 122.14-0.84.*x(1)-0.42.*x(2)+0.34.*x(3)-0.09.*x(4)+363.77.*x(5); end function [state,options,optchanged] = stop40_80(options,state,flag) optchanged = false; switch flag case 'init' case 'iter' % Find the best objective function, and stop if it is right range mask = state.Score >= 40 & state.Score <= 80; if any(mask) state.StopFlag = 'range statisfied'; state.Score = state.Score(mask); state.Population = state.Population(mask,:); state.Best(end) = state.Score(end); end case 'done' end end this is my calling function of GA for 1st equation:- A = []; b = []; Aeq = []; beq = []; lb = [29 160 30 0 0.040]; ub = [50 180 60 20 0.069]; nonlcon = []; obj = @(x) (strength(x)-80).^2; bestx = ga(obj, 5, A, b, Aeq, beq, lb, ub, nonlcon, options); display(bestx) display(strength(bestx)) All I want is use this data (output) from 1st equation for finding the answer of 2nd equation whose fitness function is given hereand variable x(1) to x(5) variable are same from 1st equation. just a new variable x(6) is added. s= -463.21-3.05.*x(1)+5.21.*x(2)+0.54.*x(3)+0.11.*x(4)-6541.17.*x(5)+41.67.*x(6); lower and upper bound of x(6)- lb=1.50 ub=9.0

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject,
20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8
+1 (416) 849-8900