我如何将这个matlab代码转换为python?

时间:2015-02-24 13:35:36

标签: python arrays matlab numpy

我想从matlab到python(numpy)编写以下操作。

repmat(总和(数据,2),1,20);

1 个答案:

答案 0 :(得分:0)

查看What is the equivalent of MATLAB's repmat in NumPy

我会建议像

这样的东西
import numpy as np
np.tile(np.sum(data, axis=1), 1, 20)

axis=1指的是求和的维数。据我记得,matlab用1开始索引计数,在python / numpy中以0开头。

希望这就是你要找的东西。