Search code examples
matlabmatrixcellcell-array

MATLAB: How to modify the dimension of a cell's matrices


I have a cell of matrices with the same number of columns and different number of rows

x = 

[210x15 double]  [220x15 double]   [236x15 double]

How can I reduce all matrices to the same minimum number of rows discarding them? In this case it would be 210:

x = 

[210x15 double]  [210x15 double]   [210x15 double]

Solution

  • Try this -

    cellfun(@(c) c(1:min(cellfun(@(c) size(c,1),x)),:),x,'uni',0)