I have the following code
o = ones(4,3,2)
c = cellfun(@squeeze,num2cell(o,[2 3]), 'UniformOutput', false)
which gives as expected the 4 cells, each containing 3x2 matrixes.
But if I reduce the last dimension of o to one, the behavior is totally not as expected:
o = ones(4,3,1)
c = cellfun(@squeeze,num2cell(o,[2 3]), 'UniformOutput', false)
The output is:
[1x3 double]
[1x3 double]
[1x3 double]
[1x3 double]
Whereas I would expect:
[3x1 double]
[3x1 double]
[3x1 double]
[3x1 double]
Any possiblity how to obtain the correct result?