Given a cell array of n elements (n > 1), each element being a 2-d array with x=k number of rows and y columns (variable across cell elements), what would be the best way to down-sample each cell element by randomly removing samples in the y-dim to match the shortest y length across all cell elements?
The snippet below is a mis-implementation and only for n=2, but goes in the right direction (I hope). Any help would be greatly appreciated, thanks!
sizeShortest = min(cellfun('size', data, 2));
sizeLongest = max(cellfun('size', data, 2));
idx = randperm(sizeLongest);
data = cellfun(@(x) x(:,idx(1:sizeShortest)), data, 'UniformOutput', false);
I guess I could use a for loop to go through each cell of the data array and check whether this element has a y length longer than the shortest y of all cells and randomly remove samples. But there's probably a better solution..
Thanks!