calculate mean af cell
6 ビュー (過去 30 日間)
古いコメントを表示
I have a cell with 30 rows., In each row there are 39 columns. Every ten folders belong to one person. For each column I want to calculate the average value for the ten folders and give this value instead of 10 different amounts. then do it for folders from 11 to 20 and 21 to 30.
7 件のコメント
採用された回答
Azzi Abdelmalek
2014 年 7 月 12 日
編集済み: Azzi Abdelmalek
2014 年 7 月 13 日
clear out
m1=reshape(1:30,10,3);
for k=1:3
m=data_matrix(m1(:,k));
f=num2cell(reshape([m{:}],39,[])',1);
out{1,k}=arrayfun(@(x) mean(cell2mat(f{x}'),2),1:39,'un',0);
end
out=repmat(out,10,1)
out=out(:)
9 件のコメント
その他の回答 (1 件)
Roger Stafford
2014 年 7 月 12 日
If your "cell" is an ordinary 'double' 30 x 39 array, A, do this:
B = [mean(A(1:10,:),1);mean(A(11:20,:),1);mean(A(21:30,:),1)];
or else this:
B = reshape(mean(reshape(A,10,[]),1),3,[]);
Either method should work.
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!