Writing m*n matrix into single array
    5 views (last 30 days)
  
       Show older comments
    
I want to write m*n matrix into single array
4 Comments
  Walter Roberson
      
      
 on 3 Nov 2017
				Yes? You can reshape(A,3,3) to get back the original ?
We do not understand what you are starting with and what you need to end up with ??
  dpb
      
      
 on 4 Nov 2017
				
      Edited: dpb
      
      
 on 5 Nov 2017
  
			All the elements of A(:) are identical to those in the original A; only the shape was changed. The expansion to vector is in column-major order; that is each column is in turn appended to the preceding. This is internal Matlab storage order and an extremely important concept in learning to use the vector facilities within Matlab.
All that occurs is, as Walter notes, a reordering of the apparent shape such that matrix operations can be performed on the matrix according to the laws of matrix algebra or elemental operations on conformant arrays.
Answers (1)
  Walter Roberson
      
      
 on 3 Nov 2017
        YourMatrix(:)
would give a column vector containing the same elements, if that is what you want ?
0 Comments
See Also
Categories
				Find more on Creating and Concatenating Matrices in Help Center and File Exchange
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

