21/07/2014

MATLAB always stores the single dimension and multidimensional arrays or matrix elements in column major order i.e MATLAB first allocates the first column in computer memory then it allocates the second column in computer memory and so on until all the columns of the respective array or matrix have been stored in computer memory.
 The following examples will better explain each and every thing what is stated above.
1 dimensional array:
                              These are the column vectors and row vectors.They can be visualized as a series of values laid out in a row or column, with a single subscript used to access individual array elements from computer memory
for example:  we have an array i.e
                                  
in computer memory it will be stored as
How MATLAB stores multidimensional arrays/matrix in computer memory.
This is how MatLab stores one dimensional array.


Where first column is representing memory locations(address) that MATLAB assigns to each element, 2nd column is explaining what is column major order principle that MATLAB follows to store elements in memory where each different color is representing different columns, and third column is used to represent position of elements in array that we use to access our elements from memory locations through MATLAB.
2 dimensional array/matrix:
for example we have a 3×3 matrix i.e

In computer memory it will be stored as stated "column major order" i.e explained below.
How MATLAB stores multidimensional arrays/matrix in computer memory.
This is how MatLab stores two dimensional array.
Again the first column is used to represent memory locations(address) that MATLAB assigns to each element, 2nd column is used to explain column major order principle that MATLAB follows to store array elements in computer memory where each different color is representing different columns, and third column is used to represent position of elements in array that we use to access our elements from memory locations.
3 dimensional array/matrix:
 suppose we have a 2×2×2 matrix, now you can see bellow that MATLAB  stores it in the same way.
How MATLAB stores multidimensional arrays/matrix in computer memory.
This is how MatLab stores three dimensional array.


Now again you can see that the first column is used to represent memory locations(address) that MATLAB assigns to each element, 2nd column is used to explain column major order principle that MATLAB follows to store array elements in computer memory where each different color is representing different columns, and third column is used to represent position of elements in array that we use to access our elements from memory locations.

All higher level multidimensional arrays are stored in the same way.




0 comments:

Post a Comment

Blog Archive

Popular Posts