[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Reshaping a 4D array to 2D

From: Przemek Klosowski
Subject: Re: Reshaping a 4D array to 2D
Date: Thu, 12 Mar 2020 16:29:30 -0400
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.2.1

On 3/12/20 3:42 PM, Brett Green wrote:
The documentation simply states that column-major order is used, which if I understand correctly preserves the last index (in the case of a matrix the column, in this case data), as I wanted.

What do you mean by 'preserving the last index'?  Column-major means that the first index changes first, i.e. for a square matrice reshape() picks elements down the first column, then second column, etc.:

reshape([1 2 ;3 4],1,4)
ans =

   1   3   2   4

For your 4-dimensional array, the elements are taken in this order: H(1,1,1,1),H(2,1,1,1),H(3,1,1,1), etc. and put in the reshaped array also in the 'first column, then second column, and so on' order.

 reshape([1 2 ;3 4;5 6;7 8],2,4)
ans =

   1   5   2   6
   3   7   4   8

reply via email to

[Prev in Thread] Current Thread [Next in Thread]