Yesterday I asked how to write code to visit every combination of N-dim vector(with entry 0,1 or 2), and it is very helpful by just trying below:
Then for i=1:3^N, trying M(i,:) is the answer. However, if I want to add constraint on those 3^N vectors, how to adjust the code?
For example I want all combinations that less than or equal to another vector V(every entry is less than or equal to V's entry). For another one, I want to try those combinations in a order, by least sum of all entries to most.
Thank you for your help!
No products are associated with this question.
I think this question is the same: http://www.mathworks.com/matlabcentral/answers/38130-pick-arrays-from-matrix-with-condition