how to find the next minimum value using if..else only?

1 view (last 30 days)
let the given values are, b1(k)=195, b1(k+1)=190,and p1(k)=204,p1(k+1)=187,
p11(k)=220,p111(k)=188,p11(k+1)=203,p111(k+1)=171.
I need to find the optimal value of p1(k) and p1(k+1).
suppose,
ax= abs(b1(k)-p1(k)) + abs(b1(k+1)-p11(k+1))= 22
bx= abs(b1(k)-p1(k)) + abs(b1(k+1)-p111(k+1))=28
cx= abs(b1(k)-p11(k)) + abs(b1(k+1)-p1(k+1))=28
dx= abs(b1(k)-p11(k)) + abs(b1(k+1)-p11(k+1))=55
ex= abs(b1(k)-p11(k)) + abs(b1(k+1)-p111(k+1))=44
fx=abs(b1(k)-p111(k)) + abs(b1(k+1)-p1(k+1))=10
gx=abs(b1(k)-p111(k)) + abs(b1(k+1)-p11(k+1))=20
hx=abs(b1(k)-p111(k)) + abs(b1(k+1)-p111(k+1))=26
I need to find the optimal value of p1(k) and p1(k+1) out of available 8 combinations with 3 conditions. The 8 combinations are
1. p1(k),p11(k+1)
2. p1(k),p111(K+1)
3. p11(k),p1(k+1)
4. p11(k),p11(k+1)
6. p11(k),p111(k+1)
7. p111(k),p1(k+1)
8. p111(k),p11(k+1)
9. p111(k),p111(k+1).
and the 3 conditions are
1. The absolute difference between p1(k),p1(k+1) must be between 0 to 15.
2. Any one value out of p1(k) or p1(k+1) must be greater than 192.
3. I should consider first the minimum value among 'ax' to 'hx'
The actual probelem i am facing is, when i choose the smallest value 'fx'=10 then its corresponding values are p1(k)=p111(k)=188 and
p1(k+1)=p1(k+1)=187 ,,,here both the values are less than 192.i dont know how to check for the next lowest value i.e 'gx'=20.
  2 Comments
Image Analyst
Image Analyst on 16 May 2017
Why the restriction that you can only use if/else in your code? Don't you just want to solve the problem no matter how? Why limit yourself?
aditya sahu
aditya sahu on 17 May 2017
Dear sir, it is also ok by using any techhnique.

Sign in to comment.

Answers (0)

Community Treasure Hunt

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

Start Hunting!