Python重塑为Matlab重塑翻译

时间:2016-04-19 14:11:55

标签: python matlab numpy

我有以下Python代码,我想在MATLAB中运行。什么是numpy' reshape语法的MATLAB等价物。

import numpy as np
a = np.random.randn(3,4,5)
for i in range(len(a)):
    b = np.reshape(a, [a.shape[i], -1], order = 'F')

1 个答案:

答案 0 :(得分:1)

而不是计算维度的-1,而是MATLAB中的would simply use []

for k = 1:ndims(a)
    b = reshape(a, size(a, k), []);
end