1> A = rand (2, 3, 4); 2> A 3 4 A (:,:, 1) = 5 6 0.0878 0.4073 0.6183 7 0.6821 0.6563 0.3876 8 9 10 A (:,:, 2) = 11 12 0.2322 0.2636 0.377713 0.7890 0.8359 0.145814 15 16 A (:,:, 3) = 17 18 0.4592 0.0751 0.142919 0.6121 0.6748 0.804420 21 22 A (:,:, 4) = 23 24 0.7069 0.5983 0.284625 0.7527 0.2629 0.040926 27> B = permute ((:, 1, :), [1 3 2]); % (:, 1, :) indicates taking the first one of the three columns (2, 3, 4, [1 3 2] indicates that the matrix is changed to [2, 4, 3]; 28> B29 30 B = 31 32 0.0878 0.2322 0.4592 0.706933 0.6821 0.7890 0.6121 0.7527
Function: in MATLAB and freemat, this function sorts an array by a specified vector.
Syntax format: B = permute (A, order) sorts the dimensions of a according to the order specified by the vector order. The elements in B are identical to those in. However, the subscript used for accessing the same element in A and B is different because of the re-arrangement. The elements in order must be different. Explain B = permute (A (:, 1, :), [1 3 2]); (:, 1, :) indicates taking 3 columns (2, 3, 4) [1 3 2] indicates that the matrix is changed to [2, 4, 3].
How to extract a two-dimensional matrix from a three-dimensional matrix in MATLAB using permute