15,947,785 members
See more:
```lets say we have the equation

t = 122.14-0.84.*x(1)-0.42.*x(2)+0.34.*x(3)-0.09.*x(4)+363.77.*x(5);

It have 5 variables and have some lower and upper bounds. i perform genetic algorithm and got optimum values as answers. now whatever value I got for these 5 variables. I want to use them in another equation which is-

s = - 463.21-3.05x(1) + 5.21x(2)+0.54x(3) +0.11x(4)-6541.17x(5) + 41.67x(6).

It have 6 variables ( variable x(1) to x(5) are same ) and x(6) is unknown and have some lower and upper bounds. here, i want the output from my previous equation as an input of x(1) to x(5) variable in 2nd equation and x(6) will be treated as unknown variables having some bounds.

PS:- Since whenever I run a genetic algorithm, the output of first equation is going to change, i want your help in the code in which the output of x(1) to x(5) variable from 1st equation will automatically get assigned in my 2nd equation. now, i hope you got it. thank you for taking interest in question.

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;
state.StopFlag = 'range statisfied';
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```
Posted