MATLAB: Function ‘subsindex’ is not defined for values of class ‘cell’.

cell arrays

Please guide me.
a = [1,0,1;1,1,0;1,1,1];
b = [0,1;1,0];
allcomb = [];
When I run this below command
cell2mat(allcomb(num2cell(a,2),num2cell(b,2)))
I have error "Function 'subsindex' is not defined for values of class 'cell'."

Best Answer

One possible way of generating your desired output:
a = [1,0,1;1,1,0;1,1,1];
b = [0,1;1,0];
[rowa, rowb] = ndgrid(1:size(a, 1), 1:size(b, 1));
allcomb = [a(rowa, :), b(rowb, :)]