2012-10-08 10 views
19

Bir programı matlab'dan Python'a çeviriyorum.matlab'ın "permute" python içinde

B = PERMUTE(A,ORDER) rearranges the dimensions of A so that they 
% are in the order specified by the vector ORDER. The array produced 
% has the same values as A but the order of the subscripts needed to 
% access any particular element are rearranged as specified by ORDER. 
% For an N-D array A, numel(ORDER)>=ndims(A). All the elements of 
% ORDER must be unique. 

Python/numpy eşdeğer bir yöntem var mı:

matlab kodu yöntemi Permute kullanır?

+0

[numpy.rollaxis] (http://docs.scipy.org/doc/numpy/reference/generated/numpy.rollaxis.html#numpy.rollaxis) yakındadır ... – mgilson

+2

@Maurits Bu rastgele bir permütasyon. Matlabda "permute" işlevinin açıklamasında rastlantısal bir şey olmadığı için rasgele olmadığını varsayalım ... – LynnH

+0

@ user1729698 Benim hatam. – Maurits

cevap

22

Bu, numpy.ndarray içinde transpose işlevine aktarılır. Varsayılan davranış siparişi tersine çevirir, ancak kendi siparişinizin bir listesini sağlayabilirsiniz.

+0

Teşekkürler, bu gerçekten çözüm oldu :) – LynnH

İlgili konular