只需使用索引和存儲在細胞中提取的矩陣更容易處理:
joined_means = cell2mat(splitted_data_means);
用或者只是爲了赫克 - 的 - 它:
data = rand(64500,17);
Nsubsets = 5;
Nsubsize = size(data,1)/Nsubsets;
splitted_data = cell(Nsubsets ,1);
splitted_data_means = cell(Nsubsets,1);
for ii=1:Nsubsets
splitted_data{ii} = data((ii-1)*Nsubsize + (1:Nsubsize),:);
splitted_data_means{ii} = mean(splitted_data{ii});
end
然後你可以加入這些手段單線:
joined_means = cell2mat(arrayfun(@(ii) mean(data((ii-1)*12900+(1:12900),:)),(1:5)','uni',false));
這將是更簡單的@ angainor的mat2cell
:
joined_means = cell2mat(cellfun(@mean,mat2cell(data, 12900*ones(5,1), 17),'uni',false));
'repmat'或'12900 * ones(5,1)' –