If your cell array only contains two sets (each with arbitrary size):
c1 = {{[1 2],[2 3]}, {[10 11], [11 12]}}
assert(numel(c1) == 2, 'only works with two sets')
[idx1, idx2] = ndgrid(1:numel(c1{1}), 1:numel(c1{2});
c2 = arrayfun(@(i1, i2) [c1{1}(i1), c1{2}(i2)], idx1(:), idx2(:), 'UniformOutput', false);
c2 = vertcat(c2{:})
A completely generic version that works with any number of sets:
c1 = {{[1 2],[2 3]}, {[10 11], [11 12]}, {4, 5, [6 7]}}
indices = cell(1, numel(c1));
ndgridin = cellfun(@(c) 1:numel(c), c1, 'UniformOutput', false);
[indices{:}] = ndgrid(ndgridin{:});
indices = cellfun(@(idx) reshape(idx, [], 1), indices, 'UniformOutput', false);
catfun = @(nset, subsets) [arrayfun(@(n, i) c1{n}{i}, nset, subsets, 'UniformOutput', false)];
c2 = arrayfun(@(varargin) catfun(1:numel(c1), [varargin{:}]), indices{:}, 'UniformOutput', false);
c2 = vertcat(c2{:})
Best Answer