C is a matrix with doubles in it
In that case,
function caTable = makeCaTable(caCM)
chopped = cellfun(@(x) chop(x, 0), caCM(1, :), 'UniformOutput', false)';
NumberOfCells = cellfun(@(m) size(m, 1), chopped);
NumberOfCells = repelem(NumberOfCells , NumberOfCells );
Frame = repelem((1:size(chopped, 1))', NumberOfCells);
chopped = cell2mat(chopped);
PosX = chopped(:, 1);
PosY = chopped(:, 2);
caTable = table(Frame, PosX, posY, NumberOfCells);
end
As a rule you shouldn't be using cell arrays unless you need to, they're slower to process and takes a lot more memory than a matrix (15 times more if each cell is just a scalar double).
Note that I'm replicating the number of cells for all rows of a frame instead of having '-' for all rows but the first of the frame. It's rarely a good idea to mix numbers and characters in a variable. If you want a different value for all but the first row, I'd recommend using NaN instead. It's trivially done:
NumberOfCells = repelem(NumberOfCells, NumberOfCells);
NumberOfCells([false; diff(NumberOfCells) == 0]) = NaN;
If you really want a '-', then it's slightly more complicated:
ncells = repelem(NumberOfCells, NumberOfCells);
NumberOfCells = num2cell(ncells);
NumberOfCells([false; diff(NumberOfCells) == 0]) = {'-'};