Loop ,Comparison for each element

2 views (last 30 days)
Suizwati
Suizwati on 11 Jul 2013
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 Comments
Suizwati
Suizwati on 12 Jul 2013
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 on 12 Jul 2013
Edited: Image Analyst on 12 Jul 2013
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.

Sign in to comment.

Answers (0)

Categories

Find more on Loops and Conditional Statements in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!