Saturday, 28 September 2013

matlab vector with element condition and sum vector condition

matlab vector with element condition and sum vector condition

I'm trying to create a random vector who contains 5 elements (from 0 to 1)
with 2 condition
All elements have to be smaller than 0.5
The sum of the vector needs to be 1
For instance this vector is not allowed (because one element is bigger
than 0.5)
[0.6, 0.1, 0.1, 0.1, 0.1]
For instance this vector is not allowed (because the sum is bigger than 1)
[0.4, 0.2, 0.2, 0.2, 0.2]
For instance this vector is allowed
[0.3, 0.25, 0.15, 0.15, 0.15]

No comments:

Post a Comment