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