Average certain rows in 3D matrix

Hi I have a 3D matrix X(63x180x360), I need to average the following elements:
X(4,:,:),X(5,:,:),X(6,:,:),X(9,:,:),X(11,:,:),X(17,:,:),X(28,:,:),X(38,:,:),X(43,:,:),X(50,:,:),X(57,:,:);
It should give me back a 3D matrix, is there a simple way, or even a general way to average certain rows

2 件のコメント

James Tursa
James Tursa 2016 年 5 月 25 日
If you are doing an average, how do you get back a 3D matrix? For your example, what is the dimension of the result you want?
Nadine
Nadine 2016 年 5 月 25 日
You're so right, I've been thinking about it too, the final dimension would be something like X(1,180,360)

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

回答 (2 件)

dpb
dpb 2016 年 5 月 26 日

0 投票

Can you write an expression to select the desired rows? If so, simply
ix=[4:6 9 11...]; % whatever is the logic to select the desired rows
mn=mean(x(ix,:,:),1);
Trivial example...
>> x=randn(3,2,5);
>> ix=[1,3];
>> mn=mean(x(ix,:,:),1);
>> whos x mn
Name Size Bytes Class Attributes
mn 1x2x5 80 double
x 3x2x5 240 double
>>
James Tursa
James Tursa 2016 年 5 月 26 日

0 投票

Is this what you want?
rows = [4 5 6 9 11 17 28 38 43 50 57];
Y = mean(X(rows,:,:),1);

カテゴリ

ヘルプ センター および File ExchangeLoops and Conditional Statements についてさらに検索

タグ

質問済み:

2016 年 5 月 25 日

回答済み:

2016 年 5 月 26 日

Community Treasure Hunt

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

Start Hunting!

Translated by