I want to run code for each (nonempty) 'sub-vector' of some vector v
. For example:
v=1:3; % [1,2,3]
Pv = subsets(v); % { [1,2,3], [1,2], [1,3], [2,3], [1], [2], [3], [] }
for s in Pv
% do things depending on each s in Pv;
end
But I do not know of any subsets(...)
in matlab. How can this be done?
Note the collection of subsets of a vector is not the same as the collection of permutations.