finding the mean for large data

2 ビュー (過去 30 日間)
FIR
FIR 2012 年 11 月 30 日
I have 3 rows ans 192 column,i want to find mean for each 9 columns in row wise,
for ex if i have rand(3,192)
taking 3x9 , i need mean in row wise so i will have 3x1 matrix after finding mean
please help
for each 3x9 i want to perform
  2 件のコメント
Jos (10584)
Jos (10584) 2012 年 11 月 30 日
192 is not divisible by 9, so what to do with the last columns?
Image Analyst
Image Analyst 2012 年 11 月 30 日
It's not "large" either. Before I read it I thought that he was talking hundreds of millions of elements, not five hundred and something. (And there is a "bug" for the case of calculating the mean for large numbers of singles)

サインインしてコメントする。

回答 (2 件)

Andrei Bobrov
Andrei Bobrov 2012 年 11 月 30 日
編集済み: Andrei Bobrov 2012 年 11 月 30 日
A = rand(3,192);
n = 9;
s = size(A);
out = squeeze(nanmean(reshape([A nan(s(1),mod(-s(2),n))],s(1),n,[]),2));
or
out = blockproc(A,[1 n],@(x)mean(x.data));
or
k = s(2) - rem(s(2),n);
out = [squeeze(mean( reshape(A(:,1:k),s(1),[]),2 )) , mean(A(:,k+1:end),2)];

Jan
Jan 2012 年 11 月 30 日
A = rand(3, 192);
B = reshape(A(:, 1:189), 3, 9, []);
C = squeeze(mean(B, 2));

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

タグ

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by