I have a cell-array of matrices (A
):
And want to convert this into a singular 2D matrix by padding each column to an equal length (in this case - 197) and reshaping it in a specific manner such A{1,1} occupies the first three columns of the output matrix, A{1,2} occupies the next three and so forth.
The latter can likely be achieved via horzcat
however I am not sure how to pad a cell array when each cell contains a matrix - rather than a vector, where i'd normally use something along the lines of:
Lmax = max(max(cell2mat(cellfun(@numel,A,'un',0)))) ;
b = cellfun(@(c)[c(:);NaN(Lmax-numel(c),1)],A,'uniformoutput',0);
Padding with either NaNs or 0's is acceptable.
How can I do this?