필터 지우기
필터 지우기

averaging

조회 수: 2 (최근 30일)
ricco
ricco 2011년 11월 9일
I have a matrix composed of 12 columns representing depths from 1 to 12 and I have thousands of rows which represent 2 minute intervals at which the measurements were taken. how could I change the values to show hourly averages? As in average every 30 rows! I've tried using reshape to do this but cant get my head around it.
thanks

답변 (3개)

Andrei Bobrov
Andrei Bobrov 2011년 11월 9일
d=randi(127,90,12);
out = squeeze(mean(reshape(d.',size(d,2),30,[]),2)).';
or
n = 30;
a = zeros(size(d)./[n 1]);
k1 = (n-1:-1:0);
for j1 = 1:size(d,1)/n
k = j1*n - k1;
a(j1,:) = mean(d(k,:));
end
or 2
out2 = blockproc(d,[30, size(d,2)],@(block_struct)mean(block_struct.data))

Fangjun Jiang
Fangjun Jiang 2011년 11월 9일
d=rand(90,12);
[M,N]=size(d);
e=mat2cell(d,30*ones(M/30,1),N);
f=cellfun(@mean,e,'uni',false);
g=cell2mat(f);

ricco
ricco 2011년 11월 10일
both work perfect, thanks.

카테고리

Help CenterFile Exchange에서 Correlation and Convolution에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by