MATLAB: How to make cells consistent in dimensions by shortening

cell arraysMATLAB

Hi,
I have cell array P which contains something like this:
< 15×1 double > < 14×1 double > < 16×1 double > < 14×1 double >…
I'd like to concatenate all these into a single cell so I did the following:
Summary.D ={cell2mat(P)};
However, I got an error due to the inconsistent dimensions of different cells above. Since the number of rows in those cell range from 14 to 16, I could just reduce all the 14×1. However, I'm not sure how to shorten these cells. Could anyone help?
Thanks.

Best Answer

This works:
P = {cell(14,1) cell(16,1)}
P{1} = rand(14,1)
P{2} = rand(16,1)
Q = [];
for k1 = 1:size(P,2)
Q = [Q; cell2mat(P(k1))];
end
Q % Display result