Averaging every n step column and m step row

Hi, Please help me to resolve the problem I have matrix 3D 8x84 below
X is time (January 2004 - January 2012)
Y is longitude
Z is Value
X = [01-2004 01-2004 01-2004 01-2004 01-2004 01-2004 01-2004 01-2004
02-2004 02-2004 02-2004 02-2004 02-2004 02-2004 02-2004 02-2004
: : : : : : : :
12-2011 12-2012 12-2012 12-2012 12-2012 12-2012 12-2012 12-2012]
Y = [40 50 60 70 80 90 100 110
40 50 60 70 80 90 100 110
: : : : : : : :
40 50 60 70 80 90 100 110]
Z = [23 35 63 45 23 34 55 32
14 23 34 43 18 26 44 22
: : : : : : : :
21 43 65 22 86 43 66 33]
I want to averaging this matrix every month in every longitude. This would averaging Value at row 1,13,25,37,49,61,73, on longitude(1,1) So I have 3D matrix 8 x 12 (8 point longitude and 12 point monthly) Anyone can help?

 採用された回答

m0xty Wilopo
m0xty Wilopo 2013 年 5 月 7 日

0 投票

Thank you Andrei, this is the fastest way to solve my inquiry
Very happy! Cheers

1 件のコメント

Jan
Jan 2013 年 5 月 7 日
Please accept the answer, which has solved you question. Comments to answers are wanted in the comment section, not as additional answer. Thanks.

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

その他の回答 (1 件)

Andrei Bobrov
Andrei Bobrov 2013 年 5 月 7 日

1 投票

Z = randi([14 66],108,8); % eg
mns = ndgrid(1:12,2004:2012);
[ln,ln] = ndgrid(1:numel(mns),1:8);
Zout=accumarray([repmat(mns(:),size(ln,2),1),ln(:)],Z(:),[],@mean);

1 件のコメント

m0xty Wilopo
m0xty Wilopo 2013 年 5 月 11 日
This is accepted answer

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

カテゴリ

ヘルプ センター および File ExchangeMatrix Indexing についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by