How can this MATLAB code be translated to Python?
For example with random files:
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]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With