MATLAB: How to generate uniformly random varaibles with inequality constraints

inequality constraintsrandom number generator

Hi,
I have two variables function f(c1,c2) and I would like to randomly generates c1 and c2 with the constraints that
  • Maximum >= f(c1,c2)>=C here C is a constant, which is less than the optima for f in a constraint area
  • c1>=0, c2>=0,
  • c1+c2<=100
Do you know you to realize this? For example, as in the image below, I would like take a random point of (c1,c2) in the darkest blue area.

Best Answer

Add IF CONDITION BRKEAK END in the loop will do. Set the iteration to a really big number to make sure(with a really small probability to fail) that the loop will generate at least one set of c1 and c2 satisfy the condition3.
LOL why in this thread is only myself ask and answer...