how to find the next minimum value using if..else only?
2 次查看(过去 30 天)
显示 更早的评论
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 个评论
Image Analyst
2017-5-16
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?
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Point Grey Hardware 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!