我想在python中翻译这个matlab代码
例如随机文件:
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
Run Code Online (Sandbox Code Playgroud)
有人可以给我一些帮助吗?谢谢!
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]
Run Code Online (Sandbox Code Playgroud)