如何将这段 MATLAB 代码转换为 Python?
例如,对于随机文件:
FileA = rand([10,2]);
FileB = randperm(10);
for i=1:10
fileC(FileB(i),1)=FileA(i,1); %for the x
fileC(FileB(i),2)=FileA(i,2); %for the y
end
import numpy as np
array_a = np.random.rand(10,2)
array_b = np.random.permutation(range(10))
array_c = np.empty(array_a.shape, array_a.dtype)
for i in range(10):
array_c[array_b[i], 0] = array_a[i, 0]
array_c[array_b[i], 1] = array_a[i, 1]
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)