我有一个3×55矩阵int
s。我想围绕其中间的每一行。这得到正确的答案,但它是丑陋的:更优雅的方式找到在茱莉亚矩阵行的平均值
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]
任何想法?
我有一个3×55矩阵int
s。我想围绕其中间的每一行。这得到正确的答案,但它是丑陋的:更优雅的方式找到在茱莉亚矩阵行的平均值
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]
任何想法?
编辑:
您可以使用逐元素减函数,.-
,计算每一行和其平均值之间的区别:
points .- mean(points, 2)
这不提供答案这个问题。要批评或要求作者澄清,请在其帖子下方留言。 - [来自评论](/ review/low-quality-posts/10156839) – ElGavilan
@ElGavilan我已经编辑了答案,以澄清任何澄清请求。 –
在我看来,它正确地提供了原始问题的答案, –
工作的呢? 'points = points - mean(points,1)' – C8H10N4O2
可能的重复:[矩阵的平均值](http://stackoverflow.com/questions/19148013/mean-row-of-matrix) – C8H10N4O2