how can I get the mean of each two columns of a matrix ?

19 ビュー (過去 30 日間)
Niki
Niki 2016 年 7 月 8 日
コメント済み: Star Strider 2016 年 7 月 8 日
I have a big matrix and I want to get the average of each 2 columns,
Is there any function to do that ?

採用された回答

Star Strider
Star Strider 2016 年 7 月 8 日
I’m not quite sure what you want.
See if this works for you:
M = randi(99, 10);
RM = reshape(M, 10, 2, [])
Mmean = mean(RM,2)
  2 件のコメント
Niki
Niki 2016 年 7 月 8 日
編集済み: Niki 2016 年 7 月 8 日
@Star Strider average of each two columns should give me 1 column . means average of each element . Let say if I have 100 columns in my original data, it should give me 50 columns
Star Strider
Star Strider 2016 年 7 月 8 日
I forgot a squeeze call. This will do what you want, and should work with any matrix:
M = randi(99, 10); % Create Data
RM = reshape(M, size(M,1), 2, []) % Reshape
Mmean = squeeze(mean(RM,2)) % Desired Result

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

その他の回答 (1 件)

Thorsten
Thorsten 2016 年 7 月 8 日
mean(reshape(mean(X), 2, []))
  1 件のコメント
Niki
Niki 2016 年 7 月 8 日
編集済み: Niki 2016 年 7 月 8 日
@Thorsten average of each two columns should give me 1 column . means average of each element . Let say if I have 100 columns in my original data, it should give me 50 columns

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

カテゴリ

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