2012-10-08 8 views
19

में मैटलैब की "परमिट" मैं मैटलैब से पायथन तक एक प्रोग्राम का अनुवाद कर रहा हूं।पाइथन

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. 

वहाँ अजगर/NumPy में एक समान विधि है:

matlab कोड विधि दूसरे स्थान पर रखना का उपयोग करता है?

+0

[numpy.rollaxis] (http://docs.scipy.org/doc/numpy/reference/generated/numpy.rollaxis.html#numpy.rollaxis) करीब है ... – mgilson

+2

@ मॉरिट्स यह यादृच्छिक क्रमपरिवर्तन है। चूंकि matlab में फ़ंक्शन "परमिट" के विवरण में यादृच्छिक के बारे में कुछ भी नहीं है, मुझे लगता है कि यह यादृच्छिक नहीं है ... – LynnH

+0

@ user1729698 मेरी गलती। – Maurits

उत्तर

22

यह में numpy.ndarray में फ़ंक्शन में घुमाया गया है। डिफ़ॉल्ट व्यवहार ऑर्डर को उलट देता है, लेकिन आप अपने ऑर्डर की एक सूची प्रदान कर सकते हैं।

+0

धन्यवाद, यह वास्तव में समाधान था :) – LynnH