I want to create an average 2d field every 10 timesteps within a 3d matrix (6000 x 100 x100) --> (600 x 100 x100)
조회 수: 1 (최근 30일)
이전 댓글 표시
I have for example a 3d matrix like (6000 x 100 x 100) with the first array being time, or the vector I want to average. How can I create an average every 10 days so that I am left with 600 x 100 x 100, so that 10 timesteps have been averaged to produce one 2d field matrix.
I have tried using accumarray but I can't seem to get it to work...and I have tried the following code (after permuting matrix):
for x = 1:100; x for y = 1:100;
aa = squeeze(data(x,y,:));
test(x,y) = nanmean(aa(1:10:end));
end
end
but then I am not sure what to do next...
Can someone help me?
thanks, Michael
댓글 수: 0
채택된 답변
Guillaume
2014년 10월 14일
Reshape your matrix into a 3d array of size 10x600x100x100 and calculate the average of that along the first dimension:
tdata = reshape(data, 10, 600, 100, 100);
mdata = squeeze(mean(tdata));
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!