フィルターのクリア

Mean of Matrix Rows

2 ビュー (過去 30 日間)
Vince Smith
Vince Smith 2019 年 5 月 18 日
コメント済み: Star Strider 2021 年 8 月 22 日
For any matrix A, how would I subtract the row means from each row, so that each row has a mean of zero?

採用された回答

Star Strider
Star Strider 2019 年 5 月 18 日
The row means would be calculated as the mean of dimension 2.
Try this:
A = rand(5);
Anew = A - mean(A,2);
Check = mean(Anew,2) % Confirm: Mean = 0
  2 件のコメント
Yugal Kishore
Yugal Kishore 2021 年 8 月 22 日
sorry for activating this old thread but proved quite useful.
If I need to do a column means for the same problem statement, how would I do that. One way is to do a transpose of the matrix. I couldn't find anything in the documentataion.
Star Strider
Star Strider 2021 年 8 月 22 日
No worries!
To do column means, use mean without any extra arguments (it defaults to taking the column means), or specifying 1 as the dimension (instead of 2).
.

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

その他の回答 (0 件)

カテゴリ

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