mean

6 ビュー (過去 30 日間)
Bahareh
Bahareh 2011 年 10 月 22 日
I have a 76x5 matrix and would like to convert this to a 76x1 matrix whose rows are the mean of each of the rows of the original matrix. Can anybody help me?
Thanks in advance.

採用された回答

Mitch Martelli
Mitch Martelli 2011 年 10 月 22 日
A=rand(76,5); m=mean(A,2);

その他の回答 (1 件)

Image Analyst
Image Analyst 2011 年 10 月 22 日
Did you happen to look up the help for the mean() function? If you had, you would have seen that you can specify the dimension along which to compute the mean.
rowMeans = mean(your2DArray, 2);
  4 件のコメント
Image Analyst
Image Analyst 2011 年 10 月 22 日
Very strange that you tried my answer and had some difficulties with it and then you tried Mitch's answer and had it work when our two answers are 100% identical, other than the names of the variables. I have no explanation unless I see your code. Sorry you wasted an hour with my code.
Jan
Jan 2011 年 10 月 22 日
+1. Your code is trivial, but the suggestion to read the help text of MEAN is perfect, because it will solve 10.000 further questions very efficiently.
I do not understand, why Mitch accepts his own answer.

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

カテゴリ

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