Mean of Matrix Rows
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Vince Smith
am 18 Mai 2019
Kommentiert: Star Strider
am 22 Aug. 2021
For any matrix A, how would I subtract the row means from each row, so that each row has a mean of zero?
0 Kommentare
Akzeptierte Antwort
Star Strider
am 18 Mai 2019
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 Kommentare
Yugal Kishore
am 22 Aug. 2021
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
am 22 Aug. 2021
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).
.
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Creating and Concatenating Matrices finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!