MATLAB: How to average the rows of a matrix in 10 groups inside a cell array

cell arrayconcatenategroupingmean

I have a 3476x18x525 matrix named 'weekdata' which I have manipulated as follows to arrive at cell array C.
N = size(weekdata,3);
C = cell(1,N);
for k = 1:N
idx = weekdata(:,3,k)==0 & weekdata(:,4,k)==0 & weekdata(:,5,k)==1 & weekdata(:,6,k)==0;
tmp = weekdata(idx,:,k);
tmp = sortrows(tmp,8);
tmp = tmp(:,2);
C{k} = tmp;
end
C is a 1×525 cell array that looks something like
C = [725x1 double, 745x1 double, 750x1 double, 732x1 double, etc...]
For each cell, I want to turn each matrix into a uniform 10×1 double, in which each row is the average of 1/10 of the rows, in order to concatenate from a cell array into a single matrix. For example, in C{1,3}, the resulting 10×1 would have (1,1) as the average of rows 1:75, (2,1) has the average of rows 76:150, and so on. However, due to the varying size of the matrices in each cell and because many of those sizes are not divisible by 10, I am not sure if this is possible.
Any ideas are welcome. Thanks.

Best Answer

Inside the loop of my original answer:
>> tmp = (1:17).'; % fake data
>> grp = 3; % pick how many groups you want (e.g. 10).
>> idy = diff(round((0:grp)*numel(tmp)/grp)) % how to split data
idy =
4 5 4
>> tmp = cellfun(@mean,mat2cell(tmp,idy)) % average of each group
tmp =
3.5000
9.0000
14.5000