I cannot understand this for life.
I am trying to remove any other element in the second axis of the array. I did it in MATLAB with arr(:,:,2:2:end) = []; but when I tried to do the same in Python and compared the two outputs, I get a different matrix.
I tried arr = np.delete(arr,np.arange(0,arr.shape[2],2),2) and arr = arr[:,:,1::2] , but none of them came up with something that i get with matlab.
Example:
MATLAB
disp(['before: ',str(arr[21,32,11])]) arr(:,:,2:2:end) = []; disp(['after: ',str(arr[21,32,11])])
exit:
before: 99089 after: 65699
Python
print 'before: ' + str(arr[20,31,10]) arr = arr[:,:,1::2]
exit:
before: 99089 after: 62360
I hope I donβt miss something fundamental.
python numpy matlab
David
source share