Use allcomb
to generate all possible combinations and then select 15 random ones from it -
Code
list_all_colors = allcomb([0 0.5 1],[0 0.5 1],[0 0.5 1])
num_rand_colors = 15 %%// Number of colors needed
rand_colors = list_all_colors(randi(size(list_all_colors,1),num_rand_colors,1),:)
If you don't want to use allcomb
and have Neural Network Toolbox, you may use combvec
, like this to generate all such combinations (code snippet from here ) -
vectors = {[0 0.5 1], [0 0.5 1], [0 0.5 1]}
list_all_colors = combvec(vectors{:})'