Dear all,
I have nested cell array as shown in the attached picture. I wanted to convert it into a Matrix but that doesn't work so easily using cell2mat. So I thought I could try to make them all the same size then I could open them up with cell2mat. To open them up I would take the length of my maximum array and add zeros to the rest of my arrays to have them the same size. I used this to do that:
maxLength = max(cellfun(@numel,A)); % A is the name of my cell array
out=(cellfun(@(x)cat(2,x,zeros(1,maxLength-length(x))),A,'UniformOutput',false)); %Filling the cells with zeros
But I don't get extra cells with zeros, instead I am getting one cell that is holding all the zeros, I have attached a picture of my result.
So my question is, what am I doing wrong? Or is there a different approach of turning my nested cell arrays into a matrix??
Thank You
Best Answer