Loop ,Comparison for each element

1 次查看(过去 30 天)
Suizwati
Suizwati 2013-7-11
Hello everyone.. I would to ask a question regarding to optimization problem. I have 2 control variable denotes as x1 and x2. The fitness function is y=x1+x2..Value of x1 and x2 will be generate by random. Let say I have this value.. x1=(1,3,4,7,9) , x2=(2,4,6,8,10) , y=( 3,7,10,15,19). I want to compare each elements of y in order to update the new location of x1 and x2 which is y1<y1, y1<y2 & y2<y2 , y1<y3 & y2<y3 & y3<y3 , y1<y4 & y2<y4 & y3<y4 & y4<y4 and y1<y5 & y2<y5 & y3<y5 & y4<y5 & y5<y5. Can anybody help on how to write the algorithm.
tq
  3 个评论
Suizwati
Suizwati 2013-7-12
i want to compare each value of the fitness. if the conditions is not true. it will maintain the fitness from previous value. Meanwhile if the condition is true it will update the value of x1 and x2 becomes x1_new and x2_new and produce the new fitness.
Image Analyst
Image Analyst 2013-7-12
编辑:Image Analyst 2013-7-12
We still don't understand "the new location of x1 and x2 which is y1<y1, y1<y2 & y2<y2 , y1<y3 & y2<y3 & y3<y3 , y1<y4 & y2<y4 & y3<y4 & y4<y4 and y1<y5 & y2<y5 & y3<y5 & y4<y5 & y5<y5. " First of all, you can never have y1<y1 or y2<y2 or y3<y3 or y4<y4 or y5<y5 so what you are trying to do? Secondly, the new location of x1 and x2 would be a boolean if you are doing all those comparisons. What does it mean that the new location is true or false? The new location must be an index, from 1 to "end" in integer steps, not a boolean.

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Loops and Conditional Statements 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by