How to extract a two-dimensional matrix from a three-dimensional matrix in MATLAB using permute

Source: Internet
Author: User
Tags sorts
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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.