Calculating mean over multiple dimensions

I have a 3-dimensional variable that is of the class double, example: data has 50x2000x999. I would like to compute the mean for the 3rd dimension first, then the second dimension, and then the first dimension.
I know one way to do this is:
meandata = mean(data,3)
meandata = mean(meandata,2)
meandata = mean(meandata).
Is there a more efficient way to do this? In one line of code probably?
Thanks,
Akul

回答 (1 件)

madhan ravi
madhan ravi 2019 年 2 月 17 日
編集済み: madhan ravi 2019 年 2 月 17 日

2 投票

mean(data,'all') % or
mean(data,[3 2 1])

1 件のコメント

madhan ravi
madhan ravi 2019 年 2 月 17 日
編集済み: madhan ravi 2019 年 2 月 17 日
For prior versions:
mean(data(:))

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

カテゴリ

ヘルプ センター および File ExchangeTest Model Components についてさらに検索

質問済み:

2019 年 2 月 17 日

編集済み:

2019 年 2 月 17 日

Community Treasure Hunt

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

Start Hunting!

Translated by