multi dimensional array and the mean function

1 回表示 (過去 30 日間)
Rica
Rica 2012 年 11 月 19 日
Hi!
How to apply the mean function on multidimenssional array?
% A=[1 2 3; 4 5 6]---> B=mean(A,2).
how to applay it on an array of the size 10*1*30?
Thnk you

回答 (2 件)

Rica
Rica 2012 年 11 月 19 日
I found the solution.
First squeeze and then apply the mean function
  1 件のコメント
Rica
Rica 2012 年 11 月 19 日
B=mean(squeeze(A),2)

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


Jan
Jan 2012 年 11 月 19 日
There is no need to squeeze:
B = mean(A, 3)
The result is [10 x 1], because trailing singleton dimensions are reduced automatically, e.g. [10 x 1 x 1] gets [10 x 1] without calling squeeze.
Try size(zeros(10, 1, 1)).

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by