Reputation: 1565
I have a 3x55 matrix of int
s. I want to center each row around its mean. This gets the right answer, but it's ugly:
row_mean = mean(points,[2])
points[1,:] = points[1,:] - row_mean[1]
points[2,:] = points[2,:] - row_mean[2]
points[3,:] = points[3,:] - row_mean[3]
Any ideas?
Upvotes: 1
Views: 508
Reputation: 5756
EDITED:
You can use the element-wise minus function, .-
, to calculate the difference between each row and its mean value:
points .- mean(points, 2)
Upvotes: 4